/* Chapel Pointe · Sunday Scorecard — shared components.
   Class names are documented in docs/FRONTEND.md; every component is showcased on /styleguide. */

/* =========================================================================================
   Icons
   ========================================================================================= */
.icon {
  width: var(--icon-size, 20px);
  height: var(--icon-size, 20px);
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}
.icon--sm { --icon-size: 16px; }
.icon--lg { --icon-size: 24px; }

/* =========================================================================================
   Buttons
   ========================================================================================= */
.btn {
  --btn-h: var(--btn-h-md, 40px);   /* phones raise the default sizes (--btn-h-*: tokens.css) */
  --btn-px: 18px;
  --icon-size: 18px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--btn-h);
  padding: 0 var(--btn-px);
  border: 1px solid transparent;
  border-radius: var(--radius-input);
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-decoration: none;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.btn:active:not(:disabled):not([aria-disabled="true"]) { transform: translateY(0.5px); }
.btn:disabled, a.btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
/* aria-disabled keeps a not-ready button focusable and clickable, so pressing it can say what is
   missing ("looks unavailable, tells you why"). It looks disabled and doesn't react to hover. */
button.btn[aria-disabled="true"] { opacity: 0.45; cursor: default; }
.btn .icon:first-child:not(:last-child) { margin-left: -3px; }
.btn .icon:last-child:not(:first-child) { margin-right: -4px; }

.btn--primary { background: var(--brand); color: var(--on-brand); }
.btn--primary:hover { background: var(--brand-hover); }

.btn--secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.btn--secondary:hover { background: var(--surface-2); border-color: var(--muted); }

.btn--ghost { color: var(--ink-2); }
.btn--ghost:hover, .btn--ghost[aria-expanded="true"] { background: var(--wash-strong); color: var(--ink); }

.btn--quiet {
  --btn-h: auto;
  --btn-px: 0;
  gap: 6px;
  color: var(--ink-2);
  border-radius: var(--radius-xs);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 0.25em;
}
.btn--quiet:hover { color: var(--ink); text-decoration-color: var(--line-strong); }

.btn--danger {
  color: var(--clay-ink);
  border-color: color-mix(in srgb, var(--clay) 45%, transparent);
}
.btn--danger:hover { background: var(--clay-soft); border-color: var(--clay); }

.btn--danger-solid { background: var(--clay); color: #FFFFFF; }
.btn--danger-solid:hover { background: color-mix(in srgb, var(--clay) 88%, #000); }
:root[data-theme="dark"] .btn--danger-solid { color: var(--on-brand); }
:root[data-theme="dark"] .btn--danger-solid:hover { background: color-mix(in srgb, var(--clay) 90%, #FFF); }

/* No hover response on an aria-disabled button (it stays clickable — see above). */
.btn--primary[aria-disabled="true"]:hover { background: var(--brand); }
.btn--secondary[aria-disabled="true"]:hover { background: var(--surface); border-color: var(--line-strong); }
.btn--ghost[aria-disabled="true"]:hover { background: transparent; color: var(--ink-2); }
.btn--quiet[aria-disabled="true"]:hover { color: var(--ink-2); text-decoration-color: transparent; }
.btn--danger[aria-disabled="true"]:hover { background: transparent; border-color: color-mix(in srgb, var(--clay) 45%, transparent); }
.btn--danger-solid[aria-disabled="true"]:hover { background: var(--clay); }

/* A not-ready primary keeps its shape and identity — the brand colour, unlit — with a label you
   can still read (never a flat grey slab). Same recipe in both themes, tuned by tokens. */
.btn--primary:disabled,
a.btn--primary[aria-disabled="true"],
button.btn--primary[aria-disabled="true"],
button.btn--primary[aria-disabled="true"]:hover {
  opacity: 1;
  background: var(--primary-disabled-bg);
  border-color: var(--primary-disabled-line);
  color: var(--primary-disabled-ink);
  box-shadow: none;
}

.btn--sm { --btn-h: var(--btn-h-sm, 32px); --btn-px: 12px; --icon-size: 16px; font-size: var(--fs-13); gap: 6px; }
.btn--lg { --btn-h: 48px; --btn-px: 24px; font-size: var(--fs-15); }
.btn--xs { --btn-h: var(--btn-h-xs, 26px); --btn-px: 8px; --icon-size: 15px; font-size: var(--fs-12); gap: 4px; border-radius: var(--radius-sm); }
.btn--icon { width: var(--btn-h); padding: 0; }
.btn--icon .icon { margin: 0 !important; }
.btn--block { display: flex; width: 100%; }
.btn--pill { border-radius: var(--radius-pill); }

.btn.is-loading { color: transparent !important; pointer-events: none; opacity: 1; }
.btn--primary.is-loading { background: var(--brand); border-color: transparent; }
.btn.is-loading .icon { visibility: hidden; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-color: var(--on-brand) var(--on-brand) var(--on-brand) transparent;
  opacity: 0.85;
  animation: cp-spin 0.75s linear infinite;
}
.btn--secondary.is-loading::after, .btn--ghost.is-loading::after { border-color: var(--ink-2) var(--ink-2) var(--ink-2) transparent; }

.btn-group { display: inline-flex; gap: var(--space-2); align-items: center; }

/* =========================================================================================
   Form fields
   ========================================================================================= */
.field { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.field__label { font-size: var(--fs-14); font-weight: 500; line-height: 1.35; color: var(--ink); }
.field__label .field__optional { color: var(--muted); font-weight: 400; margin-left: 6px; }
.field__hint { font-size: var(--fs-13); color: var(--muted); line-height: 1.45; }
.field__error {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--clay-ink);
  font-size: var(--fs-14);
  line-height: 1.4;
  --icon-size: 16px;
}
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-4); }

.input, .textarea, .select {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-input);
  box-shadow: var(--shadow-inset);
  color: var(--ink);
  font-size: var(--fs-body);
  line-height: 1.4;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 0.9; }
.input:hover, .textarea:hover, .select:hover { border-color: var(--line-strong); }
.input:focus, .textarea:focus, .select:focus,
.input:focus-visible, .textarea:focus-visible, .select:focus-visible {
  outline: none;
  background: var(--input-bg-focus);
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent);
}
:root[data-theme="dark"] :is(.input, .textarea, .select):focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 26%, transparent);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--clay);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--clay) 14%, transparent);
}
.input:disabled, .textarea:disabled, .select:disabled { opacity: 0.55; cursor: not-allowed; }
.input[readonly] { background: transparent; box-shadow: none; }

.input--sm { min-height: 32px; padding: 5px 10px; font-size: var(--fs-13); }
.input--lg { min-height: 48px; padding: 12px 16px; font-size: var(--fs-16); }
.input--num { font-variant-numeric: tabular-nums; text-align: right; }
.input--code { text-align: center; letter-spacing: 0.3em; font-size: var(--fs-18); }
.input--code:placeholder-shown { letter-spacing: 0.02em; font-size: var(--fs-16); }
.input--code[type="password"]:not(:placeholder-shown) { font-family: Verdana, system-ui, sans-serif; letter-spacing: 0.22em; }

.textarea {
  min-height: 88px;
  padding: 12px 14px;
  line-height: var(--lh-body);
  resize: none;
  overflow: hidden;
}
.textarea--reading, .textarea--serif { font-size: var(--fs-comment); line-height: var(--lh-comment); }   /* --serif: deprecated alias, now Jost */
.textarea--sm { min-height: 64px; }

.input-icon { position: relative; display: block; }
.input-icon > .icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  --icon-size: 18px;
}
.input-icon > .input { padding-left: 36px; }
.input-icon > .input--sm { padding-left: 32px; }
.input-icon > .input--sm + .icon, .input-icon > .icon:has(+ .input--sm) { left: 9px; --icon-size: 16px; }

.select-wrap { position: relative; display: block; }
.select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  background: var(--muted);
  pointer-events: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 7.5l5 5 5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 7.5l5 5 5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.select--sm { min-height: 32px; padding-top: 5px; padding-bottom: 5px; font-size: var(--fs-13); }

/* Checkbox & radio — <label class="check"><input class="check__input" type="checkbox"><span class="check__box"></span>Label</label> */
.check {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-14);
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.check__input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.check__box {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--input-bg-focus);
  color: var(--on-brand);
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
  --icon-size: 14px;
}
.check__box .icon { stroke-width: 2.2; opacity: 0; transform: scale(0.6); transition: opacity var(--dur-fast), transform var(--dur-fast) var(--ease-out); }
.check:hover .check__box { border-color: var(--muted); }
.check__input:checked + .check__box { background: var(--brand); border-color: var(--brand); }
.check__input:checked + .check__box .icon { opacity: 1; transform: none; }
.check__input:focus-visible + .check__box { outline: 2px solid var(--focus); outline-offset: 2px; }
.check__input:disabled + .check__box { opacity: 0.5; }
.check--radio .check__box { border-radius: 50%; }
.check--radio .check__box::after {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--on-brand);
  transform: scale(0);
  transition: transform var(--dur-fast) var(--ease-out);
}
.check--radio .check__input:checked + .check__box::after { transform: scale(1); }

/* Switch — <label class="switch"><input class="switch__input" type="checkbox" role="switch"><span class="switch__track"></span>Label</label> */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-14);
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.switch:hover { color: var(--ink); }
.switch__input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.switch__track {
  position: relative;
  width: 34px;
  height: 20px;
  flex: none;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background-color var(--dur) var(--ease-out);
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--switch-thumb);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out);
}
.switch__input:checked + .switch__track { background: var(--brand); }
.switch__input:checked + .switch__track::after { transform: translateX(14px); background: var(--on-brand); }
.switch__input:focus-visible + .switch__track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch__input:disabled + .switch__track { opacity: 0.5; }
.switch--sm { font-size: var(--fs-13); }

/* =========================================================================================
   Chips (single & multi select)
   ========================================================================================= */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
/* Chips are a min-height, not a fixed height, and their words keep a real line box (1.3): with
   `line-height: 1` a label's box is shorter than Jost's descenders, so anything that clips it
   (an ellipsis span, a zoomed or Present-sized label) cut the bottom off "g", "p" and "y". */
.chip {
  --icon-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--fs-14);
  font-weight: 450;
  line-height: var(--lh-snug);
  white-space: nowrap;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.chip:hover { border-color: var(--muted); color: var(--ink); background: var(--surface-2); }
.chip[aria-checked="true"], .chip[aria-pressed="true"], .chip.is-selected {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}
.chip .chip__check { display: none; stroke-width: 2; }
.chip[aria-checked="true"] .chip__check, .chip[aria-pressed="true"] .chip__check { display: block; margin-left: -3px; }
.chip__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--muted)); flex: none; }
.chip__meta { color: inherit; opacity: 0.6; font-size: var(--fs-12); }
.chip:disabled { opacity: 0.45; }
.chips--sm .chip { min-height: 28px; padding: 0 11px; font-size: var(--fs-13); }
.chips--lg .chip { min-height: 40px; padding: 0 18px; font-size: var(--fs-15); }

/* =========================================================================================
   Choice cards — big selectable cards (survey venue picker, Manage blueprints)
   ========================================================================================= */
.choice-cards { display: grid; grid-template-columns: repeat(var(--choice-cols, 2), minmax(0, 1fr)); gap: var(--space-3); }
.choice-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  min-height: 112px;
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  text-align: left;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.choice-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.choice-card[aria-checked="true"], .choice-card[aria-pressed="true"] {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), var(--shadow-md);
}
:root[data-theme="dark"] .choice-card:hover { background: var(--surface-2); }
:root[data-theme="dark"] .choice-card[aria-checked="true"], :root[data-theme="dark"] .choice-card[aria-pressed="true"] { background: var(--surface-2); }
.choice-card__media { min-height: 28px; display: flex; align-items: center; padding-right: 30px; --logo-h: 22px; }
.choice-card__title { display: flex; align-items: center; gap: 8px; font-size: var(--fs-15); font-weight: 500; line-height: 1.3; }
.choice-card__meta { font-size: var(--fs-13); color: var(--ink-2); line-height: 1.4; }
.choice-card__check {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  color: transparent;
  --icon-size: 14px;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.choice-card__check .icon { stroke-width: 2.2; }
.choice-card[aria-checked="true"] .choice-card__check, .choice-card[aria-pressed="true"] .choice-card__check {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}
/* Pick-several cards (choiceCards({ multiple: true })): the tick sits in a rounded square, the
   checkbox shape, so they never read as one-of-a-kind radio cards. */
.choice-cards--multi .choice-card__check { border-radius: 6px; }

/* =========================================================================================
   Segmented control
   ========================================================================================= */
.segmented {
  display: inline-flex;
  align-items: stretch;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-sunken);
  border: 1px solid var(--hairline);
}
.segmented__option {
  --icon-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 7px;
  color: var(--ink-2);
  font-size: var(--fs-13);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast);
}
.segmented__option:hover { color: var(--ink); }
.segmented__option[aria-checked="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(30, 26, 24, 0.08), 0 0 0 1px var(--hairline);
}
:root[data-theme="dark"] .segmented__option[aria-checked="true"] {
  background: var(--surface-raised);
  box-shadow: inset 0 1px 0 var(--edge-highlight), 0 0 0 1px var(--line-strong), 0 1px 3px rgba(0, 0, 0, 0.4);
}
.segmented--sm .segmented__option { min-height: 24px; padding: 0 9px; font-size: var(--fs-12); }
.segmented--lg .segmented__option { min-height: 36px; padding: 0 16px; font-size: var(--fs-14); }

/* =========================================================================================
   Tabs (underline)
   ========================================================================================= */
.tabs {
  display: flex;
  align-items: flex-end;
  gap: 28px;
  border-bottom: 1px solid var(--hairline);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0 13px;
  color: var(--ink-2);
  font-size: var(--fs-15);
  font-weight: 450;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-out);
}
.tab:hover { color: var(--ink); }
.tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand);
  transform: scaleX(0);
  transition: transform var(--dur) var(--ease-out);
}
.tab[aria-selected="true"] { color: var(--ink); font-weight: 500; }
.tab[aria-selected="true"]::after { transform: scaleX(1); }
.tab:focus-visible { outline-offset: -2px; }
.tab__count {
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--wash-strong);
  color: var(--ink-2);
  font-size: var(--fs-11);
  font-weight: 500;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.tabs--sm { gap: 20px; }
.tabs--sm .tab { font-size: var(--fs-14); padding: 9px 0 10px; }

/* =========================================================================================
   Cards
   ========================================================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  min-width: 0;
}
.card--flush { padding: 0; }
.card--lg { padding: var(--space-6); }
.card--inset { background: var(--surface-2); box-shadow: none; }
.card--quiet { background: transparent; box-shadow: none; }
.card--interactive {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
.card--interactive:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.card__title { font-family: var(--font-serif); font-style: normal; font-size: var(--fs-card-title); font-weight: 500; line-height: var(--lh-snug); letter-spacing: -0.005em; }
.card__subtitle { margin-top: var(--space-1); font-size: var(--fs-14); line-height: 1.45; color: var(--ink-2); }
.card__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--hairline);
}

/* =========================================================================================
   Section card — mirrors the paper scorecard (numbered bronze badge, serif title, kicker)
   ========================================================================================= */
.section-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6) var(--space-6) var(--space-3);
}
.section-card__head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--space-3);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--bronze-line);
}
.section-card__title {
  font-family: var(--font-serif);
  font-style: normal;
  font-size: var(--fs-section);
  font-weight: 450;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.section-card__kicker { justify-self: end; text-align: right; padding-left: var(--space-4); }
/* The intro under a section title: Jost, upright, a calm second voice. */
.section-card__intro {
  margin-top: var(--space-4);
  max-width: var(--measure);
  font-size: var(--fs-16);
  line-height: var(--lh-lede);
  color: var(--ink-2);
}
.section-card__body { margin-top: var(--space-1); }
.section-card + .section-card { margin-top: var(--space-5); }

.section-badge {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--bronze-badge);
  box-shadow: inset 0 0 0 1px var(--bronze-badge-ring);
  color: var(--on-bronze);
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  font-weight: 600;
  line-height: 1;
  --icon-size: 16px;
}
.section-badge--sm { width: 22px; height: 22px; font-size: var(--fs-11); --icon-size: 13px; }
.section-badge--outline { background: transparent; color: var(--bronze-ink); box-shadow: inset 0 0 0 1px var(--bronze-line); }

/* "This Sunday" add-on section: bronze top rule + icon badge + warm wash */
.section-card--moment {
  border-top: 3px solid var(--bronze);
  background:
    linear-gradient(to bottom, var(--tone-glow), transparent 140px),
    var(--surface);
}
:root[data-theme="dark"] .section-card--moment { border-top-width: 2px; }

/* Tone card — the hero / "Next Sunday" pattern for pages: a raised card with a thin bronze
   (champagne, in Present) top rule and soft light from above. */
.tone-card {
  --surface: var(--surface-tone);   /* nested cards, buttons and face-pile rings sit flush with it */
  position: relative;
  background:
    linear-gradient(to bottom, var(--tone-glow), transparent 180px),
    var(--surface-tone);
  border: 1px solid var(--hairline);
  border-top: 3px solid var(--bronze);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}
:root[data-theme="dark"] .tone-card { --surface-2: var(--surface-raised); border-top-width: 2px; }
.section-card--moment .section-card__head { border-bottom-color: var(--bronze-line); }

/* Group heading inside a section — "▍Worship" */
.group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: var(--space-5);
  margin-bottom: 0;
  font-family: var(--font-serif);
  font-style: normal;
  font-size: var(--fs-18);
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.group-title::before {
  content: "";
  width: 3px;
  height: 1.05em;
  border-radius: 2px;
  background: var(--bronze);
}

/* =========================================================================================
   Question rows (rendered by components/question.js)
   ========================================================================================= */
.q {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--space-6);
  row-gap: var(--space-3);
  padding: 20px 0;
}
.q + .q { border-top: 1px solid var(--hairline); }
.group-title + .q { border-top: 0; }
.q--block { grid-template-columns: minmax(0, 1fr); align-items: stretch; }
.q__text { min-width: 0; }
.q__label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  font-size: var(--fs-16);
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink);
}
.q__label-text { min-width: 0; }
/* Jost even beside a Newsreader headline label (Overall Health). */
.q__req { font-family: var(--font-sans); font-style: normal; letter-spacing: 0.01em; color: var(--bronze-ink); font-size: var(--fs-12); font-weight: 500; }
/* Help under a question: Jost, regular, muted — supporting, never competing with the label. */
.q__help {
  margin-top: var(--space-1);
  max-width: var(--measure);
  font-size: var(--fs-help);
  font-weight: 400;
  line-height: var(--lh-help);
  color: var(--muted);
}
.q__control { display: flex; align-items: center; gap: 12px; min-width: 0; }
.q--block .q__control { display: block; }
.q__row { display: flex; align-items: center; gap: 12px; }
.q__error { grid-column: 1 / -1; }
.q__clear {
  font-size: var(--fs-13);
  color: var(--muted);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}
/* After the circles in the DOM (tab order), to their left on screen (they never move). */
.q__control > .q__clear { order: -1; }
.q:hover .q__clear, .q:focus-within .q__clear { opacity: 1; }
.q__clear:hover { color: var(--ink); text-decoration: underline; }
.q.is-invalid .q__label-text { color: var(--clay-ink); }

/* Notes questions read like the paper card's "WORSHIP NOTES" line — and start one line tall */
.q--notes .textarea { min-height: 64px; }
.q--notes .q__label { font-family: var(--font-brand); font-size: var(--fs-11); font-weight: 700; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--ink-2); }
.q--headline .q__label { font-family: var(--font-serif); font-style: normal; font-size: var(--fs-20); font-weight: 500; letter-spacing: -0.005em; }

/* Read-only answers — written answers read like comments: Jost 16 / 1.6. */
.q-answer { font-size: var(--fs-15); color: var(--ink); }
.q-answer--text { font-size: var(--fs-comment); line-height: var(--lh-comment); white-space: pre-wrap; max-width: 68ch; }
.q-answer--empty { color: var(--muted); font-size: var(--fs-14); }
.q--readonly { padding: var(--space-4) 0; }

/* "New" tag */
.tag-new {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--radius-xs);
  background: var(--bronze-soft);
  color: var(--bronze-ink);
  font-family: var(--font-brand);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1;
  vertical-align: middle;
}

/* =========================================================================================
   Rating control — the signature element
   ========================================================================================= */
.rating {
  --rating-size: 36px;
  --rating-gap: 8px;
  display: inline-grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
}
.rating__circles { display: flex; gap: var(--rating-gap); }
/* No "½" toggle → no second column, so the circles end flush with the row (like Yes / No and fields). */
.rating:not(:has(.rating__half)) { column-gap: 0; }
.rating__opt {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--rating-size);
  height: var(--rating-size);
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}
.rating__opt:hover { background: var(--bronze-soft); border-color: var(--bronze-line); color: var(--ink); }
.rating__opt[aria-checked="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  animation: cp-rating-pop var(--dur) var(--ease-out);
}
.rating__opt:focus-visible { outline-offset: 3px; border-radius: 50%; }
.rating__opt .rating__half-mark { font-size: 0.78em; margin-left: 1px; }
.rating__ends {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: var(--fs-11);
  color: var(--muted);
  letter-spacing: 0.02em;
  line-height: 1;
}
.rating__ends span { width: var(--rating-size); text-align: center; }
/* Low / High once per section card: the first rating row carries them, later rows don't repeat them
   (the survey, the Manage previews and /styleguide all read the same way). */
.section-card__body .q--rating ~ .q--rating:not(.q--headline) .rating__ends { display: none; }
.rating__half {
  --icon-size: 13px;
  grid-column: 2;
  grid-row: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 28px;
  min-width: 54px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px dashed var(--bronze-line);
  color: var(--bronze-ink);
  font-size: var(--fs-13);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: background-color var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), opacity var(--dur-fast), transform var(--dur) var(--ease-out);
}
.rating__half:hover { background: var(--bronze-soft); }
.rating__half[aria-pressed="true"] { border-style: solid; border-color: var(--bronze); background: var(--bronze-soft); }
.rating__half.is-hidden { visibility: hidden; opacity: 0; transform: translateX(-4px); }
.rating--lg { --rating-size: 44px; --rating-gap: 10px; }
.rating--lg .rating__opt { font-size: var(--fs-16); }
.rating--sm { --rating-size: 28px; --rating-gap: 6px; }
.rating--sm .rating__opt { font-size: var(--fs-12); }
.rating--readonly .rating__opt { cursor: default; }
.rating--readonly .rating__opt:not([aria-checked="true"]) { background: transparent; color: var(--muted); border-color: var(--hairline); }
.rating--readonly .rating__opt:hover:not([aria-checked="true"]) { background: transparent; }
.rating--readonly .rating__opt[aria-checked="true"] { animation: none; }

@keyframes cp-rating-pop {
  0% { transform: scale(0.82); }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Yes / No pills */
.yesno { display: inline-flex; gap: 8px; }
.yesno__opt {
  min-width: 64px;
  height: 34px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--fs-14);
  font-weight: 500;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.yesno__opt:hover { border-color: var(--muted); color: var(--ink); background: var(--surface-2); }
.yesno__opt[aria-checked="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.yesno--readonly .yesno__opt { cursor: default; }
.yesno--readonly .yesno__opt:not([aria-checked="true"]) { color: var(--muted); border-color: var(--hairline); background: transparent; }

/* =========================================================================================
   Stat tiles & deltas
   ========================================================================================= */
.stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
}
.stat--plain { padding: 0; background: none; border: 0; border-radius: 0; }
.stat__label {
  --icon-size: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-14);
  font-weight: 500;
  color: var(--ink-2);
}
.stat__label .icon { color: var(--muted); }
.stat__value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: var(--fs-32);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.stat__unit { font-size: var(--fs-14); font-weight: 400; letter-spacing: 0; color: var(--ink-2); }
.stat__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: var(--fs-13); color: var(--muted); }
.stat--hero .stat__value { font-size: 64px; font-weight: 300; letter-spacing: -0.03em; line-height: 1; }
.stat--hero .stat__label { font-size: var(--fs-14); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--space-3); }

.delta {
  --icon-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: var(--fs-13);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}
.delta .icon { stroke-width: 2; }
.delta--good { color: var(--slate); }
.delta--bad { color: var(--clay-ink); }

/* =========================================================================================
   Badges, pills, avatars, kbd
   ========================================================================================= */
.badge {
  --icon-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  color: var(--ink-2);
  /* A badge stays Jost even inside a serif title ("Vision Sunday · Grandville launch  Demo"). */
  font-family: var(--font-sans);
  font-style: normal;
  letter-spacing: 0;
  font-size: var(--fs-12);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
.badge--bronze { background: var(--bronze-soft); border-color: transparent; color: var(--bronze-ink); }
.badge--clay { background: var(--clay-soft); border-color: transparent; color: var(--clay-ink); }
.badge--slate { background: var(--slate-soft); border-color: transparent; color: var(--slate); }
.badge--solid { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.badge--outline { background: transparent; border-color: var(--line-strong); }
.badge--demo { background: transparent; border: 1px dashed var(--line-strong); color: var(--ink-2); }
.badge--lg { height: 26px; padding: 0 11px; font-size: var(--fs-13); }
.badge__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot, currentColor); flex: none; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--muted)); flex: none; vertical-align: middle; }
.dot--lg { width: 10px; height: 10px; }

/* Avatar — a face photo in a circle (initials when there's no photo or it fails to load).
   Sizes: xs 24 · sm 32 · md 44 (default) · lg 64 · xl 112. The hairline ring sits over the photo (::after).
   Dense rows → sm · people lists & comment authors → md · the owner of a panel → lg · a person's page → xl. */
.avatar {
  --avatar-size: var(--avatar-md);
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--avatar-size);
  height: var(--avatar-size);
  flex: none;
  overflow: hidden;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: max(9px, calc(var(--avatar-size) * 0.36));
  font-weight: 500;
  letter-spacing: 0.03em;
  line-height: 1;
  vertical-align: middle;
  user-select: none;
  -webkit-user-select: none;
}
.avatar::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--avatar-hairline);
  pointer-events: none;
}
.avatar__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  border-radius: inherit;
  filter: var(--photo-filter);
}
.avatar--photo .avatar__initials { visibility: hidden; }
.avatar--xs { --avatar-size: var(--avatar-xs); letter-spacing: 0; }
.avatar--sm { --avatar-size: var(--avatar-sm); }
.avatar--md { --avatar-size: var(--avatar-md); }
.avatar--lg { --avatar-size: var(--avatar-lg); }
.avatar--xl { --avatar-size: var(--avatar-xl); font-weight: 400; letter-spacing: 0.02em; }
/* A venue-colour ring, offset by a sliver of the surface (style="--ring: …"). */
.avatar[style*="--ring"] { box-shadow: 0 0 0 2px var(--ring-gap, var(--surface)), 0 0 0 3.5px var(--ring); }

/* Face pile — overlapping faces with a surface ring, "+3" when there are more. */
.face-pile { display: inline-flex; align-items: center; vertical-align: middle; isolation: isolate; }
.face-pile > .avatar, .face-pile__more {
  box-shadow: 0 0 0 2px var(--pile-ring, var(--surface));
  transition: transform var(--dur-fast) var(--ease-out);
}
/* Overlap only between faces — the screen-reader label leads the pile, so the first face must not shift. */
.face-pile > .avatar ~ .avatar, .face-pile > .avatar ~ .face-pile__more { margin-left: calc(var(--avatar-size) * -0.26); }
.face-pile > .avatar:hover { transform: translateY(-2px); z-index: 1; }
.face-pile__more {
  --avatar-size: var(--avatar-md);
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--avatar-size);
  height: var(--avatar-size);
  min-width: var(--avatar-size);
  padding: 0 4px;
  flex: none;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: max(10px, calc(var(--avatar-size) * 0.34));
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.face-pile__more::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--line-strong); }
.face-pile--xs .face-pile__more { --avatar-size: var(--avatar-xs); width: auto; padding: 0 6px; }
.face-pile--sm .face-pile__more { --avatar-size: var(--avatar-sm); width: auto; padding: 0 8px; }
.face-pile--lg .face-pile__more { --avatar-size: var(--avatar-lg); }
/* Older markup: .avatar-stack behaves like a small face pile. */
.avatar-stack { display: flex; }
.avatar-stack > .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack > .avatar + .avatar { margin-left: calc(var(--avatar-size) * -0.26); }

.person { display: inline-flex; align-items: center; gap: var(--space-3); min-width: 0; }
.person__name { font-weight: 500; color: var(--ink); }
.person__meta { font-size: var(--fs-meta); color: var(--muted); }
.person__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; line-height: 1.3; }
.person:has(> .avatar--xs, > .avatar--sm) { gap: 10px; }

/* Person chip — a face + name (+ meta) for attributions: "◉ Ramsay Smith · Gatherings Coordinator". */
.person-chip { display: inline-flex; align-items: center; gap: var(--space-3); min-width: 0; max-width: 100%; vertical-align: middle; line-height: 1.3; }
.person-chip:has(> .avatar--xs, > .avatar--sm) { gap: var(--space-2); }
.person-chip__text { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 0 6px; min-width: 0; }
.person-chip__name { font-weight: 500; color: var(--ink); white-space: nowrap; }
.person-chip__meta { color: var(--muted); }
.person-chip__meta::before { content: "·"; margin-right: 6px; }
.person-chip--stacked .person-chip__text { flex-direction: column; align-items: flex-start; gap: 1px; }
.person-chip--stacked .person-chip__meta { font-size: var(--fs-meta); }
.person-chip--stacked .person-chip__meta::before { content: none; }
.person-chip--pill {
  gap: var(--space-2);
  padding: 3px 14px 3px 3px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: var(--fs-14);
}

/* Photo card — a portrait: rounded photo, name in Newsreader, title in Jost. */
.photo-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; margin: 0; }
.photo-card__media {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--surface-2);
}
.photo-card__media::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--avatar-hairline); pointer-events: none; }
.photo-card__img { width: 100%; height: 100%; max-width: none; object-fit: cover; object-position: 50% 35%; filter: var(--photo-filter); transition: transform var(--dur-slow) var(--ease-out); }
.photo-card__initials {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: var(--fs-44);
  font-weight: 400;
  color: var(--muted);
  background: linear-gradient(to bottom, var(--tone-glow), transparent), var(--surface-2);
}
.photo-card__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.photo-card__name { font-family: var(--font-serif); font-size: var(--fs-18); font-weight: 500; line-height: 1.25; letter-spacing: -0.005em; color: var(--ink); }
.photo-card__meta { font-size: var(--fs-13); color: var(--muted); line-height: 1.4; }
.photo-card__foot { margin-top: 6px; }
a.photo-card, button.photo-card { color: inherit; text-decoration: none; text-align: left; }
a.photo-card:hover .photo-card__img, button.photo-card:hover .photo-card__img { transform: scale(1.025); }

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: var(--fs-11);
  font-weight: 500;
  line-height: 1;
}

/* =========================================================================================
   Dividers, eyebrow rule, pull quotes
   ========================================================================================= */
.divider { border: 0; border-top: 1px solid var(--hairline); margin: var(--space-5) 0; }
.divider--bronze { border-top-color: var(--bronze-line); }
.divider--label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border: 0;
  margin: var(--space-5) 0;
}
.divider--label::before, .divider--label::after { content: ""; flex: 1; border-top: 1px solid var(--hairline); }
.vr { width: 1px; align-self: stretch; background: var(--hairline); flex: none; }

/* Comment — a note, reflection or quote owned by a person (lib/ui.js comment(); quote() renders
   through it). The author's face leads, name + meta beside it, the words below in Jost 16 / 1.6,
   lined up under the name. No italic: reflections are read, not admired.
   .comment > .comment__face (avatar) + .comment__main > .comment__head (.comment__name, .comment__meta)
   + .comment__kicker + .comment__body + .comment__footer */
.comment {
  --comment-face: var(--avatar-md);
  --comment-gap: 14px;
  position: relative;
  display: grid;
  grid-template-columns: var(--comment-face) minmax(0, 1fr);
  column-gap: var(--comment-gap);
  align-items: start;
  min-width: 0;
  margin: 0;
}
.comment__face { grid-column: 1; grid-row: 1; display: flex; }
/* Everything else — and anything a page appends — sits in the text column. */
.comment > :not(.comment__face) { grid-column: -2 / -1; min-width: 0; }
.comment__main { display: flex; flex-direction: column; min-width: 0; }
/* Name and meta sit centred on the face; the words start just below it. */
.comment__head {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  min-height: var(--comment-face);
  min-width: 0;
  line-height: 1.3;
}
.comment__name {
  font-size: var(--fs-15);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.005em;
}
.comment__meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.32em; font-size: var(--fs-meta); color: var(--muted); }
/* Each part carries its own trailing "·" (lib/ui.js), so a wrapped line never starts with a dot. */
.comment__meta-sep { margin-left: 0.32em; }
.comment__kicker { margin-top: var(--space-2); color: var(--muted); }
.comment__body {
  margin: var(--space-2) 0 0;
  font-family: var(--font-sans);
  font-style: normal;
  font-size: var(--fs-comment);
  font-weight: 400;
  line-height: var(--lh-comment);
  color: var(--ink);
  white-space: pre-line;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}
.comment__kicker + .comment__body { margin-top: var(--space-1); }
.comment__main > :first-child { margin-top: 0; }
.comment__footer { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-top: var(--space-3); color: var(--muted); font-size: var(--fs-13); }
/* No face (an anonymous line, or face: false): one column. */
.comment--no-face { grid-template-columns: minmax(0, 1fr); }
.comment--no-face .comment__head { min-height: 0; }
/* Sizes: sm — a 32px face, 15px words (dense lists, drawers). lg — a 64px face, 17px words (a lead
   voice): the name sits at the top of the face and the words run beside it. */
.comment--sm { --comment-face: var(--avatar-sm); --comment-gap: var(--space-3); }
.comment--sm .comment__name { font-size: var(--fs-14); }
.comment--sm .comment__body { font-size: var(--fs-15); line-height: 1.55; margin-top: 6px; }
.comment--lg { --comment-face: var(--avatar-lg); --comment-gap: 18px; }
.comment--lg .comment__head { min-height: 0; padding-top: var(--space-2); }
.comment--lg .comment__name { font-size: var(--fs-16); }
.comment--lg .comment__meta { font-size: var(--fs-14); }
.comment--lg .comment__body { font-size: var(--fs-lede); line-height: 1.6; margin-top: var(--space-3); }
.comment--no-face.comment--lg .comment__head { padding-top: 0; }

/* A stack of comments with generous room between them (commentList()). */
.comment-list { display: flex; flex-direction: column; gap: var(--comment-list-gap, var(--space-6)); min-width: 0; }
.comment-list--divided { gap: 0; }
.comment-list--divided > * { padding-block: var(--space-5); }
.comment-list--divided > * + * { border-top: 1px solid var(--hairline); }
.comment-list--divided > :first-child { padding-top: 0; }
.comment-list--divided > :last-child { padding-bottom: 0; }
.comment-list--dense { --comment-list-gap: var(--space-5); }

/* Legacy pull-quote hooks: quote() output also carries .quote / .quote__text / .quote__cite so page
   CSS that targets them keeps applying — but it is a comment now (Jost, upright, face first). */
.quote__who { color: var(--ink); font-weight: 600; }
.quote__sep { color: var(--muted); }

/* =========================================================================================
   Tables
   ========================================================================================= */
.table-wrap {
  position: relative;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
}
.table-wrap--scroll { max-height: var(--table-max-h, 520px); }
.table {
  width: 100%;
  font-size: var(--fs-14);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.table th, .table td {
  padding: 11px 16px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--hairline);
}
.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--fs-11);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  padding-top: 10px;
  padding-bottom: 10px;
}
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody tr { transition: background-color var(--dur-fast) var(--ease-out); }
.table--hover tbody tr:hover { background: var(--wash); }
.table--zebra tbody tr:nth-child(even) { background: color-mix(in srgb, var(--wash) 70%, transparent); }
.table--zebra.table--hover tbody tr:hover { background: var(--wash-strong); }
.table tbody tr.is-selected { background: var(--bronze-soft); }
.table .num, .table th.num { text-align: right; }
.table .center { text-align: center; }
.table .cell-muted { color: var(--muted); }
.table .cell-strong { font-weight: 500; }
.table tbody th { font-weight: 500; }
.table--compact th, .table--compact td { padding: 7px 12px; }
.table--compact { font-size: var(--fs-13); }
.table caption { caption-side: top; text-align: left; padding: 0 0 var(--space-2); color: var(--ink-2); font-size: var(--fs-13); }
.th-sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; --icon-size: 13px; }
.th-sort:hover { color: var(--ink); }

/* =========================================================================================
   Overlays: scrim, drawer, modal, popover, menu, listbox, tooltip, toast
   ========================================================================================= */
.scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
  animation: cp-fade-in var(--dur) var(--ease-out);
}
.overlay-root.is-closing .scrim { animation: cp-fade-out var(--dur) var(--ease-out) forwards; }
html.has-overlay { overflow: hidden; }

/* Overlays are the highest surface. Inside one, "surface" means that raised surface, so nested
   cards, stat tiles and face-pile rings sit flush with it instead of reading as darker holes. */
.drawer, .modal, .popover { --surface: var(--surface-raised); --surface-2: var(--surface-raised-2); }

.drawer-root { position: fixed; inset: 0; z-index: var(--z-drawer); }
.drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(var(--drawer-w, 560px), calc(100vw - 48px));
  background: var(--surface-raised);
  border-left: 1px solid var(--hairline);
  box-shadow: var(--shadow-lg);
  animation: cp-drawer-in var(--dur-slow) var(--ease-out);
}
.drawer-root.is-closing .drawer { animation: cp-drawer-out var(--dur) var(--ease-in-out) forwards; }
.drawer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--hairline);
}
.drawer__title { font-family: var(--font-serif); font-style: normal; font-size: var(--fs-section); font-weight: 450; line-height: 1.2; letter-spacing: -0.01em; }
.drawer__subtitle { margin-top: var(--space-1); font-size: var(--fs-15); color: var(--ink-2); }
.drawer__eyebrow { margin-bottom: var(--space-2); }
.drawer__body { flex: 1 1 auto; overflow-y: auto; padding: var(--space-5) var(--space-6) var(--space-6); overscroll-behavior: contain; }
.drawer__foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--hairline);
  background: var(--surface-raised);
}
.drawer__close { margin: -4px -8px 0 0; }

.modal-root {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--space-6);
  overflow-y: auto;
}
.modal {
  position: relative;
  width: min(var(--modal-w, 560px), 100%);
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: cp-modal-in var(--dur) var(--ease-out);
}
.modal-root.is-closing .modal { animation: cp-modal-out var(--dur) var(--ease-in-out) forwards; }
.modal--sm { --modal-w: 420px; }
.modal--md { --modal-w: 560px; }
.modal--lg { --modal-w: 760px; }
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); padding: var(--space-5) var(--space-6) 0; }
.modal__title { font-family: var(--font-serif); font-style: normal; font-size: var(--fs-section); font-weight: 450; line-height: 1.2; letter-spacing: -0.01em; }
.modal__body { padding: var(--space-3) var(--space-6) var(--space-1); overflow-y: auto; color: var(--ink-2); font-size: var(--fs-body); line-height: var(--lh-body); }
.modal__body > * + * { margin-top: var(--space-3); }
.modal__foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-5) var(--space-6) var(--space-5); }
.modal__close { margin: -4px -10px 0 0; }

.popover {
  position: fixed;
  z-index: var(--z-popover);
  min-width: 180px;
  max-width: min(420px, calc(100vw - 32px));
  max-height: min(420px, calc(100vh - 32px));
  overflow-y: auto;
  padding: 6px;
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
  animation: cp-pop-in var(--dur-fast) var(--ease-out);
  overscroll-behavior: contain;
}
.popover--padded { padding: var(--space-4); }
.modal:focus-visible, .drawer:focus-visible, .popover:focus-visible { outline: none; }

.menu { display: flex; flex-direction: column; gap: 1px; }
.menu__item {
  --icon-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: var(--fs-14);
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}
.menu__item .icon { color: var(--ink-2); }
.menu__item:hover, .menu__item:focus-visible, .menu__item.is-active { background: var(--wash-strong); outline: none; }
.menu__item[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.menu__item--danger, .menu__item--danger .icon { color: var(--clay-ink); }
.menu__item-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.menu__item-meta { color: var(--muted); font-size: var(--fs-13); }
.menu__check { visibility: hidden; color: var(--ink) !important; stroke-width: 2; --icon-size: 16px; }
.menu__item[aria-checked="true"] .menu__check { visibility: visible; }
.menu__item[aria-checked="true"] { font-weight: 500; }
.menu__label { padding: 10px 10px 4px; }
.menu__block { padding: 10px 10px 8px; }
.menu__sep { height: 1px; margin: 5px 4px; background: var(--hairline); }

.combobox { position: relative; }
.combobox__input { padding-right: 34px; }
.combobox__toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  --icon-size: 16px;
}
.combobox__toggle:hover { color: var(--ink); background: var(--wash); }
.combobox--lg .combobox__toggle { right: 8px; }
/* The chosen person's face sits inside the field (options with an `avatar`). */
.combobox__face { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.combobox--lg .combobox__face { left: 12px; }
.combobox.has-face .combobox__input { padding-left: 42px; }
.combobox--lg.has-face .combobox__input { padding-left: 54px; }
.listbox__option > .avatar { margin-left: -2px; }

.listbox { display: flex; flex-direction: column; gap: 1px; }
.listbox__group + .listbox__group { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--hairline); }
.listbox__group-label { padding: 10px 10px 4px; }
.listbox__option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 40px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink);
  font-size: var(--fs-14);
}
.listbox__option.is-active { background: var(--wash-strong); }
.listbox__option[aria-selected="true"] { font-weight: 500; }
.listbox__option-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; line-height: 1.3; }
.listbox__option-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listbox__option-meta { font-size: var(--fs-13); color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listbox__check { visibility: hidden; stroke-width: 2; --icon-size: 16px; }
.listbox__option[aria-selected="true"] .listbox__check { visibility: visible; }
.listbox__empty { padding: var(--space-3); color: var(--muted); font-size: var(--fs-14); }
.listbox mark { background: transparent; color: inherit; font-weight: 600; }

.tooltip {
  position: fixed;
  z-index: var(--z-tooltip);
  max-width: 300px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--tooltip-bg);
  color: var(--tooltip-ink);
  font-family: var(--font-sans);
  font-style: normal;
  font-size: var(--fs-13);
  line-height: 1.45;
  pointer-events: none;
  box-shadow: 0 0 0 1px var(--toast-line), 0 6px 18px rgba(0, 0, 0, 0.22);
  animation: cp-fade-in var(--dur-fast) var(--ease-out);
}
.tooltip strong { font-weight: 600; }

.toast-region {
  /* Pages with a sticky bottom bar lift toasts above it: body { --toast-offset: 96px } (or :has()). */
  position: fixed;
  left: 50%;
  bottom: var(--toast-offset, 28px);
  z-index: var(--z-toast);
  transition: bottom var(--dur) var(--ease-out);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  --icon-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  max-width: 520px;
  padding: 10px 14px 10px 14px;
  border-radius: var(--radius-card);
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: var(--fs-15);
  box-shadow: 0 0 0 1px var(--toast-line), var(--shadow-lg);
  pointer-events: auto;
  animation: cp-toast-in var(--dur-slow) var(--ease-out);
}
.toast.is-leaving { animation: cp-toast-out var(--dur) var(--ease-in-out) forwards; }
.toast__icon { opacity: 0.9; }
.toast--success .toast__icon { color: var(--toast-success); }
.toast--attention .toast__icon { color: var(--toast-attention); }
.toast--info .toast__icon { color: var(--toast-info); }
.toast__action {
  margin-left: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: inherit;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.toast__action:hover { background: rgba(127, 127, 127, 0.18); }
.toast__close { margin-right: -4px; opacity: 0.7; color: inherit; --icon-size: 16px; }
.toast__close:hover { opacity: 1; }

/* =========================================================================================
   Empty states, callouts, loading, spinner
   ========================================================================================= */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-7) var(--space-5);
}
.empty__icon {
  --icon-size: 22px;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-2);
  border-radius: 50%;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--hairline);
  color: var(--ink-2);
}
.empty__title { font-family: var(--font-serif); font-style: normal; font-size: var(--fs-card-title); font-weight: 500; line-height: 1.25; letter-spacing: -0.005em; color: var(--ink); }
.empty__body { max-width: 48ch; color: var(--ink-2); font-size: var(--fs-body); line-height: 1.55; }
.empty__action { margin-top: var(--space-3); }
.empty--compact { padding: var(--space-6) var(--space-4); }
.empty--compact .empty__icon { width: 40px; height: 40px; --icon-size: 20px; margin-bottom: var(--space-1); }
.empty--compact .empty__title { font-size: var(--fs-18); }

.callout {
  --icon-size: 20px;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-4) var(--space-4);
  border-radius: var(--radius-card);
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--fs-body);
  line-height: 1.5;
}
.callout__icon { margin-top: 1px; color: var(--ink-2); }
.callout__content { flex: 1 1 auto; min-width: 0; }
.callout__title { font-weight: 500; color: var(--ink); }
.callout__title + .callout__body { margin-top: 2px; }
.callout__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.callout--info { background: color-mix(in srgb, var(--slate-soft) 70%, var(--surface)); border-color: color-mix(in srgb, var(--slate) 16%, transparent); }
.callout--info .callout__icon { color: var(--slate); }
.callout--attention { background: color-mix(in srgb, var(--clay-soft) 55%, var(--surface)); border-color: color-mix(in srgb, var(--clay) 22%, transparent); }
.callout--attention .callout__icon, .callout--attention .callout__title { color: var(--clay-ink); }
.callout--bronze { background: color-mix(in srgb, var(--bronze-soft) 75%, var(--surface)); border-color: color-mix(in srgb, var(--bronze) 22%, transparent); }
.callout--bronze .callout__icon { color: var(--bronze-ink); }
/* Present: a gold wash over charcoal reads olive-brown across a whole callout, so the gold stays in
   the edge and the icon and the panel is a neutral lift. Stays opaque on any surface. */
:root[data-theme="dark"] .callout--bronze {
  background: linear-gradient(var(--tone-glow), var(--tone-glow)), var(--surface-2);
  border-color: var(--bronze-line);
}
.callout--compact { --icon-size: 18px; gap: 10px; padding: var(--space-3) var(--space-4); font-size: var(--fs-14); }

.spinner {
  display: inline-block;
  width: var(--spinner-size, 16px);
  height: var(--spinner-size, 16px);
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--ink-2);
  animation: cp-spin 0.8s linear infinite;
  vertical-align: middle;
}
.spinner--lg { --spinner-size: 24px; }
.loading-line { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: var(--fs-14); }

.is-loading:not(.btn) { position: relative; }
.is-loading:not(.btn) > * { opacity: 0.42; pointer-events: none; transition: opacity var(--dur) var(--ease-out); }
.is-loading:not(.btn)::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 14px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--ink);
  animation: cp-spin 0.8s linear infinite;
}

/* =========================================================================================
   Logos
   ========================================================================================= */
.logo { display: inline-block; line-height: 0; }
.logo img { height: var(--logo-h, 32px); width: auto; max-width: none; }
.logo__on-dark { display: none !important; }
:root[data-theme="dark"] .logo__on-light { display: none !important; }
:root[data-theme="dark"] .logo__on-dark { display: block !important; }
/* A /styleguide panel scoped to the other theme shows that theme's logo. */
[data-theme-scope="dark"] .logo__on-light { display: none !important; }
[data-theme-scope="dark"] .logo__on-dark { display: block !important; }
:root[data-theme="dark"] [data-theme-scope="light"] .logo__on-light { display: block !important; }
:root[data-theme="dark"] [data-theme-scope="light"] .logo__on-dark { display: none !important; }

/* =========================================================================================
   App header
   ========================================================================================= */
.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--hairline);
  transition: background-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.app-header.is-scrolled {
  background: var(--header-glass);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  box-shadow: 0 1px 0 var(--hairline), 0 6px 20px -16px rgba(30, 26, 24, 0.35);
}
.app-header--landing { background: transparent; border-bottom-color: transparent; position: absolute; left: 0; right: 0; }
.app-header__inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: 100%;
}
.app-header__brand {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 2px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
}
.app-header__brand .logo { --logo-h: 32px; }
.app-header__brand .logo--secondary { --logo-h: 31px; }
.app-header__brand .logo--campus { --logo-h: 33px; }
.app-header__product {
  font-family: var(--font-serif);
  font-size: var(--fs-18);
  font-weight: 450;
  letter-spacing: -0.005em;
  color: var(--ink);
  white-space: nowrap;
}
.app-header .vr { height: 24px; align-self: center; }

.campus-switch {
  --icon-size: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-14);
  font-weight: 500;
  white-space: nowrap;
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.campus-switch:hover, .campus-switch[aria-expanded="true"] { border-color: var(--line-strong); background: var(--surface-2); }
.campus-switch .icon { color: var(--muted); transition: transform var(--dur) var(--ease-out); }
.campus-switch[aria-expanded="true"] .icon { transform: rotate(180deg); }
.campus-switch__all {
  display: inline-grid;
  grid-template-columns: repeat(2, 4px);
  gap: 2px;
}
.campus-switch__all i { width: 4px; height: 4px; border-radius: 50%; background: var(--dot); }

.app-nav { display: flex; align-items: center; gap: 2px; }
.app-nav__link {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  color: var(--ink-2);
  font-size: var(--fs-14);
  font-weight: 450;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.app-nav__link:hover { color: var(--ink); background: var(--wash-strong); }
.app-nav__link[aria-current="page"] { color: var(--ink); font-weight: 500; background: var(--wash-strong); }
.app-header__actions { display: flex; align-items: center; gap: 4px; }
.present-toggle[aria-pressed="true"] { color: var(--ink); background: var(--wash-strong); }

/* Who is signed in: their photo + first name, opening the account menu (Switch person, Sign out). */
.identity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  margin-left: 4px;
  padding: 0 10px 0 4px;
  border-radius: var(--radius-pill);
  color: var(--ink);
  font-size: var(--fs-14);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.identity:hover, .identity[aria-expanded="true"] { background: var(--wash-strong); }
.identity__name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; }
.identity__chevron { --icon-size: 14px; color: var(--muted); margin-left: -2px; transition: transform var(--dur) var(--ease-out); }
.identity[aria-expanded="true"] .identity__chevron { transform: rotate(180deg); }
/* A session without a person (an older server): a quiet mark in the same circle. */
.identity-mark {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--avatar-sm);
  height: var(--avatar-sm);
  border-radius: 50%;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--ink-2);
  --icon-size: 16px;
}
.identity-mark--md { width: var(--avatar-md); height: var(--avatar-md); --icon-size: 20px; }
.identity-mark--lg { width: var(--avatar-lg); height: var(--avatar-lg); --icon-size: 26px; }
.popover--identity { min-width: 300px; }
/* Narrow windows: Present becomes its icon (it keeps its tooltip) so the person keeps their name. */
@media (max-width: 1120px) {
  .present-toggle .btn__label { display: none; }
  .present-toggle { --btn-px: 0; width: var(--btn-h); }
  .present-toggle .icon:first-child:not(:last-child) { margin: 0; }
}
.identity-card { display: flex; align-items: center; gap: var(--space-4); padding: 4px 2px; }

/* Below desktop: the C mark (dashboard on phones) and the page links' own row (.app-subnav). Both are
   hidden on desktop; the phone and tablet rules are in "Phones and tablets" at the end of this file. */
.app-header__mark { display: none; }
.app-subnav { display: none; }
.identity-card__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; line-height: 1.35; }
.identity-card__name { color: var(--ink); font-size: var(--fs-16); font-weight: 600; }
.identity-card__meta { color: var(--muted); font-size: var(--fs-13); }
.identity-card__access { margin-top: 8px; }

/* =========================================================================================
   Sunday picker & calendar
   ========================================================================================= */
.sunday-picker {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.sunday-picker__step {
  --btn-h: 32px;
  border-radius: 50%;
}
.sunday-picker__label {
  --icon-size: 17px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  min-width: 196px;
  padding: 0 14px;
  justify-content: center;
  border-radius: var(--radius-pill);
  color: var(--ink);
  font-size: var(--fs-14);
  font-weight: 500;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.sunday-picker__label .icon { color: var(--muted); }
.sunday-picker__label:hover, .sunday-picker__label[aria-expanded="true"] { background: var(--wash-strong); }
.sunday-picker__hint { color: var(--muted); font-weight: 400; }
.sunday-picker--lg .sunday-picker__label { height: 40px; font-size: var(--fs-15); min-width: 228px; }
.sunday-picker--lg .sunday-picker__step { --btn-h: 40px; }
.sunday-picker--compact .sunday-picker__label { min-width: 0; padding: 0 10px; }

.calendar { width: 300px; padding: 14px 14px 10px; }
.calendar__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; padding-left: 6px; }
.calendar__title { font-family: var(--font-serif); font-size: var(--fs-18); font-weight: 500; letter-spacing: -0.005em; }
.calendar__nav { display: flex; gap: 2px; }
.calendar__grid { width: 100%; table-layout: fixed; }
.calendar__grid th {
  height: 28px;
  font-size: var(--fs-11);
  font-weight: 500;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.04em;
}
.calendar__grid th:first-child { color: var(--bronze-ink); }
.calendar__grid td { padding: 1px 0; text-align: center; }
.calendar__grid td:first-child { background: var(--bronze-soft); }
.calendar__grid tr:nth-child(1) td:first-child { border-top-left-radius: 10px; border-top-right-radius: 10px; }
.calendar__grid tr:last-child td:first-child { border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; }
.calendar__day {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--ink);
  font-size: var(--fs-13);
  font-variant-numeric: tabular-nums;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.calendar__day:hover:not(:disabled) { background: var(--wash-strong); }
.calendar__day.is-outside { color: var(--muted); opacity: 0.6; }
.calendar__day.is-sunday { font-weight: 600; }
.calendar__day:disabled { color: var(--muted); opacity: 0.45; cursor: default; }
.calendar__day.is-sunday:disabled { opacity: 0.5; }
.calendar__day[aria-current="date"] { box-shadow: inset 0 0 0 1px var(--line-strong); }
.calendar__day[aria-selected="true"] { background: var(--brand) !important; color: var(--on-brand); opacity: 1; }
.calendar__day:focus-visible { outline-offset: 1px; border-radius: 50%; }
.calendar__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
}

/* =========================================================================================
   Sign-in flow (lib/auth.js): Welcome → Who are you? → personal code → in; the not-allowed view
   ========================================================================================= */
.gate {
  position: fixed;
  inset: 0;
  z-index: var(--z-gate);
  display: flex;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 var(--space-6);
  background:
    radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--surface) 80%, transparent), transparent 70%),
    var(--bg);
  color: var(--ink);
  animation: cp-fade-in var(--dur-slow) var(--ease-out);
}
.gate.is-leaving { animation: cp-fade-out 240ms var(--ease-in-out) forwards; pointer-events: none; }
/* margin: auto centres the flow when it fits and lets a long list start at the top when it doesn't —
   and as the card grows between steps, the whole block glides instead of jumping. */
.gate__inner {
  margin: auto;
  padding: clamp(28px, 7vh, 72px) 0 var(--space-7);
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: cp-gate-rise 480ms var(--ease-out) both;
}
.gate[data-size="mid"] .gate__inner { width: min(720px, 100%); }
.gate[data-size="wide"] .gate__inner { width: min(940px, 100%); margin-top: 0; }   /* a long list starts at the top and stays put while you search */
.gate__logo { --logo-h: 76px; margin-bottom: 36px; transition: margin-bottom var(--dur-slow) var(--ease-out); }
.gate__logo img { transition: height var(--dur-slow) var(--ease-out); }
.gate[data-size="wide"] .gate__logo { --logo-h: 56px; margin-bottom: 28px; }
.gate__card {
  position: relative;
  width: 100%;
  padding: var(--space-7) var(--space-6) var(--space-6);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  text-align: center;
}
.gate[data-size="wide"] .gate__card { padding: 44px 40px 36px; }
.gate__card.is-morphing { overflow: hidden; }
.gate__back { position: absolute; top: 14px; left: 14px; z-index: 3; --btn-h: 36px; color: var(--ink-2); }
.gate__eyebrow { margin-bottom: 10px; }
.gate__title { font-family: var(--font-serif); font-style: normal; font-size: var(--fs-32); font-weight: 400; letter-spacing: -0.015em; line-height: 1.12; text-wrap: balance; }
.gate__title:focus { outline: none; }
.gate__text { margin: var(--space-3) auto var(--space-5); max-width: 34ch; color: var(--ink-2); font-size: var(--fs-16); line-height: 1.55; }
.gate__mark {
  display: grid;
  place-items: center;
  width: var(--avatar-lg);
  height: var(--avatar-lg);
  border-radius: 50%;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--hairline);
  color: var(--ink-2);
  --icon-size: 26px;
}
.gate__form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.gate__form.is-shaking { animation: cp-shake 360ms var(--ease-in-out); }
.gate__error { justify-content: center; text-align: center; }
.gate__error.is-locked {
  justify-content: flex-start;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-input);
  background: var(--clay-soft);
}
.gate__error .icon { flex: none; }
.gate__notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: var(--space-3) auto var(--space-5);
  color: var(--ink-2);
  font-size: var(--fs-15);
  line-height: 1.45;
  text-align: left;
  text-wrap: balance;
  --icon-size: 16px;
}
.gate__notice .icon { flex: none; color: var(--muted); }
.gate__notice--error, .gate__notice--error .icon { color: var(--clay-ink); }
.gate__who + .gate__notice { margin: 0 auto var(--space-4); }
.gate__alt {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px var(--space-5);
  margin-top: var(--space-5);
}
.gate__alt--stack { flex-direction: column; align-items: center; gap: 6px; }
.gate__alt:empty { display: none; }
.gate__switch {
  padding: 4px 2px;
  color: var(--ink-2);
  font-size: var(--fs-14);
  border-radius: var(--radius-xs);
}
.gate__switch:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.gate__help { max-width: 46ch; color: var(--muted); font-size: var(--fs-14); line-height: 1.5; text-wrap: pretty; }
.gate__help .gate__switch { padding: 0; color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.gate__actions { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-5); }
.gate__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 4px 10px;
  margin-top: var(--space-5);
  color: var(--muted);
  font-size: var(--fs-14);
  text-align: center;
}
.gate__foot[hidden] { display: none; }
.gate__foot-sep { color: var(--line-strong); }
.gate__cancel { color: var(--ink-2); }

/* Whose step this is: the face (96–112px), name and title above the heading. */
.gate__who { display: flex; flex-direction: column; align-items: center; margin-bottom: var(--space-5); }
.gate__who > .avatar, .gate__who > .gate__mark { margin-bottom: 14px; box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--hairline); }
.gate__who-name { color: var(--ink); font-size: var(--fs-16); font-weight: 600; line-height: 1.35; }
.gate__who-meta { color: var(--muted); font-size: var(--fs-14); line-height: 1.4; }
.gate__step[data-step="pin"] .gate__title,
.gate__step[data-step="denied"] .gate__title { font-size: calc(28px * var(--type-scale)); }
.gate__step[data-step="pin"] .gate__form { margin-top: var(--space-5); }
.gate__step[data-step="denied"] .gate__title { max-width: 20ch; margin-inline: auto; }

/* ---- Who are you? ---------------------------------------------------------------------- */
.pick-wrap { display: flex; flex-direction: column; gap: var(--space-4); margin-top: var(--space-5); text-align: left; }
.pick-wrap--small { gap: var(--space-5); }
.pick-wrap .gate__error { margin: 0; }

/* "Continue as Howard Fu" — the last profile on this device. */
.pick-last {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
  padding: 12px 16px 12px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  color: var(--ink);
  text-align: left;
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.pick-last:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.pick-last:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-lg); }
.pick-last__text { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.pick-last__label { font-size: calc(17px * var(--type-scale)); font-weight: 500; line-height: 1.3; }
.pick-last__meta { color: var(--muted); font-size: var(--fs-14); line-height: 1.35; }
.pick-last__go {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  transition: background-color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
.pick-last:hover .pick-last__go, .pick-last:focus-visible .pick-last__go { background: var(--brand); border-color: var(--brand); color: var(--on-brand); transform: translateX(2px); }
.pick-or { display: flex; align-items: center; gap: var(--space-3); color: var(--muted); font-size: var(--fs-13); }
.pick-or::before, .pick-or::after { content: ""; flex: 1; height: 1px; background: var(--hairline); }

/* The search stays in reach while a long list scrolls. */
.gate__search {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 -12px;
  padding: 12px 12px 10px;
  background: var(--surface);
  transition: box-shadow var(--dur) var(--ease-out);
}
.gate__sentinel { display: block; height: 0; margin-bottom: calc(var(--space-4) * -1); }
.gate__search.is-stuck { box-shadow: 0 1px 0 var(--hairline), 0 10px 18px -16px rgba(0, 0, 0, 0.4); }
.gate--inline .gate__search { top: var(--header-h); }
.gate__search .input-icon { display: block; }
.gate__search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.pick-groups { display: flex; flex-direction: column; gap: var(--space-5); }
.pick-group[hidden] { display: none; }
.pick-group__title { display: flex; align-items: center; gap: var(--space-3); margin-bottom: 6px; }
.pick-group__title::after { content: ""; flex: 1; height: 1px; background: var(--hairline); }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 2px 6px; }
.pick-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 8px; }
.pick-row .pick { width: 148px; }
.pick {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 14px 6px 12px;
  border-radius: var(--radius-card);
  color: var(--ink);
  text-align: center;
  transition: background-color var(--dur-fast) var(--ease-out), opacity var(--dur) var(--ease-out);
}
.pick[hidden] { display: none; }
.pick__face { position: relative; display: grid; margin-bottom: 9px; }
.pick__face > .avatar { transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out); }
.pick:hover { background: var(--wash); }
.pick:hover .pick__face > .avatar, .pick:focus-visible .pick__face > .avatar {
  transform: translateY(-2px);
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 4.5px var(--line-strong), 0 10px 22px -12px rgba(0, 0, 0, 0.35);
}
.pick:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: var(--radius-card); background: var(--wash); }
.pick__name { font-size: var(--fs-14); font-weight: 500; line-height: 1.25; text-wrap: balance; }
.pick__title {
  display: -webkit-box;
  max-width: 19ch;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--muted);
  font-size: var(--fs-12);
  line-height: 1.35;
}
.pick-row .pick__name { font-size: var(--fs-15); }
.pick-row .pick__title { font-size: var(--fs-13); }
/* A profile with a personal code wears a small lock. */
.pick__lock {
  position: absolute;
  right: -1px;
  bottom: -1px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-raised);
  box-shadow: 0 0 0 2px var(--surface), inset 0 0 0 1px var(--line-strong);
  color: var(--ink-2);
  --icon-size: 13px;
}
.pick-last .pick__lock { width: 22px; height: 22px; box-shadow: 0 0 0 2px var(--surface-2), inset 0 0 0 1px var(--line-strong); }
/* Signing in as this profile. */
.is-busy .pick__face::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 55%, transparent) ;
}
.is-busy .pick__face::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--ink);
  animation: cp-spin 0.8s linear infinite;
}
.pick-wrap.is-choosing :is(.pick, .pick-last):not(.is-busy) { opacity: 0.45; pointer-events: none; }
.pick-empty { padding: var(--space-5) 0; color: var(--muted); font-size: var(--fs-15); text-align: center; }

/* Phones (staff often score from one): a 16px gutter, tighter card, three faces to a row. */
@media (max-width: 600px) {
  .gate { padding: 0 var(--space-4); }
  .gate__logo, .gate[data-size="wide"] .gate__logo { --logo-h: 56px; margin-bottom: var(--space-5); }
  .gate__card, .gate[data-size="wide"] .gate__card { padding: 44px var(--space-5) var(--space-5); }
  .gate__search { margin: 0 -8px; padding: 10px 8px 8px; }
  .pick-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .pick { padding: 10px 2px; }
  .pick-grid .pick__face > .avatar { --avatar-size: 64px !important; }
  .pick-row .pick { width: 128px; }
  .pick-row .pick__face > .avatar { --avatar-size: 80px !important; }
  .pick-last { gap: var(--space-3); padding: 10px 12px 10px 10px; }
  .pick-last .pick__face > .avatar { --avatar-size: 52px !important; }
  .pick-last__label { font-size: var(--fs-15); }
  .pick-last__go { width: 34px; height: 34px; }
}

/* The styleguide shows the flow in place. */
.gate--inline { position: relative; inset: auto; z-index: auto; min-height: 640px; overflow: visible; border-radius: var(--radius-card); animation: none; }
.gate--inline .gate__inner { animation: none; }

/* =========================================================================================
   "Where to?" — the doors for the dashboard and admin codes (lib/auth.js whereToView, the landing page)
   ========================================================================================= */
.where { display: flex; flex-direction: column; align-items: center; text-align: center; }
.where__face > .avatar { box-shadow: 0 0 0 5px var(--bg), 0 0 0 6px var(--bronze-line), 0 18px 40px -22px rgba(0, 0, 0, 0.45); }
.where__title {
  margin-top: 28px;
  font-family: var(--font-serif);
  font-style: normal;
  font-size: var(--fs-56);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.022em;
  text-wrap: balance;
}
.where__title:focus { outline: none; }
.where__lede { margin-top: 12px; color: var(--ink-2); font-size: calc(19px * var(--type-scale)); line-height: 1.4; }
.doors { display: grid; gap: var(--space-5); width: 100%; margin-top: 52px; text-align: left; }
.doors--1 { max-width: 460px; grid-template-columns: minmax(0, 1fr); }
.doors--2 { max-width: 920px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.doors--3 { max-width: 1140px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* Side by side, the doors share rows (art · eyebrow · title · body · go), so a two-line title in one
   door keeps every body and every arrow on the same line. */
@supports (grid-template-rows: subgrid) {
  .doors:not(.doors--1) { grid-template-rows: repeat(4, auto) 1fr; }
  .doors:not(.doors--1) .door { display: grid; grid-row: span 5; grid-template-rows: subgrid; row-gap: 0; }
}
.door {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 300px;
  padding: 30px 32px 28px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
.door:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.door:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: var(--radius-lg); }
.door__art { display: flex; align-items: center; height: 48px; margin-bottom: 30px; color: var(--ink-2); }
.door__eyebrow { margin-bottom: 12px; }
.door__title {
  display: block;
  font-family: var(--font-serif);
  font-size: var(--fs-32);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.015em;
  max-width: 14ch;
  text-wrap: balance;
}
.door__body { display: block; margin-top: 12px; max-width: 40ch; color: var(--ink-2); font-size: var(--fs-15); line-height: 1.55; text-wrap: pretty; }
.door__go {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 28px;
  font-size: var(--fs-14);
  font-weight: 500;
  color: var(--ink);
}
.door__arrow {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  transition: background-color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
.door:hover .door__arrow, .door:focus-visible .door__arrow { background: var(--brand); border-color: var(--brand); color: var(--on-brand); transform: translateX(3px); }

/* Door illustrations: a tiny rating row, a tiny trend line, three sliders. */
.mini-rating { display: flex; gap: 5px; }
.mini-rating i {
  display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--line-strong);
  font-style: normal; font-size: 11px; font-weight: 500; color: var(--muted);
}
.mini-rating i.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.mini-trend, .mini-sliders { width: 132px; height: 48px; overflow: visible; }
.mini-trend .target { stroke: var(--line-strong); stroke-dasharray: 2 3; }
.mini-trend .line { stroke: var(--ink); stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.mini-trend .dot { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.mini-trend .stem { stroke: var(--bronze); stroke-width: 1; stroke-dasharray: 1.5 2.5; }
.mini-trend .flag { fill: var(--bronze); }
.mini-sliders .track { stroke: var(--line-strong); stroke-width: 1.5; stroke-linecap: round; }
.mini-sliders .knob { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.mini-sliders .knob--on { fill: var(--brand); stroke: var(--brand); }

/* =========================================================================================
   Misc utilities used across pages
   ========================================================================================= */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-5); margin-bottom: var(--space-6); }
.page-head__title { font-family: var(--font-serif); font-style: normal; font-size: var(--fs-title); font-weight: 400; line-height: 1.08; letter-spacing: -0.015em; }
.page-head__lede { margin-top: var(--space-3); max-width: var(--measure); color: var(--ink-2); font-size: var(--fs-lede); line-height: var(--lh-lede); }
.page-head__eyebrow { margin-bottom: var(--space-3); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.toolbar__group { display: flex; align-items: center; gap: var(--space-2); }
.toolbar__label { font-size: var(--fs-14); color: var(--muted); }

.meta-list { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; color: var(--ink-2); font-size: var(--fs-14); }
.meta-list > * + *::before { content: "·"; margin: 0 8px; color: var(--muted); }

.copy-btn.is-copied { color: var(--slate); }

/* =========================================================================================
   Keyframes
   ========================================================================================= */
@keyframes cp-spin { to { transform: rotate(360deg); } }
@keyframes cp-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes cp-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes cp-gate-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes cp-pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes cp-drawer-in { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes cp-drawer-out { from { transform: none; opacity: 1; } to { transform: translateX(32px); opacity: 0; } }
@keyframes cp-modal-in { from { transform: translateY(8px) scale(0.985); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes cp-modal-out { from { opacity: 1; } to { transform: translateY(4px) scale(0.99); opacity: 0; } }
@keyframes cp-toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes cp-toast-out { from { opacity: 1; } to { transform: translateY(6px); opacity: 0; } }
@keyframes cp-shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

/* =========================================================================================
   Phones and tablets (ROUND5-CONTRACT §1)
   phone ≤ 600px · tablet 601–1023px · desktop ≥ 1024px. Desktop is untouched: every rule below sits
   in a max-width query. Page-only overrides live in each page's own CSS.
   Shared on phones: tap targets ≥ 44px tall (visibly, or through a centred ::before hit area on
   small buttons, chips and segments), text fields at 16px+ so iOS doesn't zoom, chips that wrap
   their words instead of cutting them, drawers and dialogs as full-screen sheets with a clear close
   button, toasts inside the gutter.
   ========================================================================================= */

/* ---- App header + page links row (tablet and phone) --------------------------------------- */
@media (max-width: 1023px) {
  .app-header .app-nav, .app-header .app-header__nav-vr { display: none; }
  .app-header__brand .logo--campus { --logo-h: 28px; }
  .campus-switch { min-width: 0; flex: 0 1 auto; }
  /* A long venue name gives way before the header does (the line box stays 1.55: no clipped tails). */
  .campus-switch > span:not(.campus-switch__all):last-of-type { min-width: 0; overflow: hidden; text-overflow: ellipsis; line-height: var(--lh-body); }

  /* The page links (Scorecard · Dashboard · Manage) in their own row, a compact segmented control.
     It sits right under the sticky header and scrolls away with the page. */
  .app-subnav:not([hidden]) {
    display: block;
    padding: var(--space-2) 0;
    background: var(--bg);
    border-bottom: 1px solid var(--hairline);
  }
  .app-subnav__track {
    display: grid;
    grid-template-columns: repeat(var(--links, 3), minmax(0, 1fr));
    gap: 2px;
    max-width: 480px;
    padding: 3px;
    border-radius: 10px;
    background: var(--surface-sunken);
    border: 1px solid var(--hairline);
  }
  .app-subnav__link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 8px;
    border-radius: 7px;
    color: var(--ink-2);
    font-size: var(--fs-14);
    font-weight: 500;
    line-height: var(--lh-snug);
    text-align: center;
    text-decoration: none;
    transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  }
  /* A 44px hit area over the 38px segment (it stays inside the track's padding). */
  .app-subnav__link::before { content: ""; position: absolute; left: 0; right: 0; top: -3px; bottom: -3px; }
  .app-subnav__link:hover { color: var(--ink); }
  .app-subnav__link[aria-current="page"] {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(30, 26, 24, 0.08), 0 0 0 1px var(--hairline);
  }
  :root[data-theme="dark"] .app-subnav__link[aria-current="page"] {
    background: var(--surface-raised);
    box-shadow: inset 0 1px 0 var(--edge-highlight), 0 0 0 1px var(--line-strong), 0 1px 3px rgba(0, 0, 0, 0.4);
  }
  .app-subnav__link:focus-visible { outline-offset: -2px; border-radius: 7px; }
}

@media (max-width: 600px) {
  .app-header__inner { gap: var(--space-2); }
  .app-header__brand { flex: none; height: var(--tap); }
  .app-header__brand .logo { --logo-h: 26px; }
  .app-header__brand .logo--campus { --logo-h: 22px; }
  /* The product label and its divider hide; on the dashboard the C mark replaces the wordmark so the
     campus switcher keeps its words. */
  .app-header__product, .app-header__lead-vr { display: none; }
  .app-header--campus .app-header__logo { display: none; }
  .app-header--campus .app-header__mark { display: inline-block; --logo-h: 30px; }
  .campus-switch { height: 40px; margin-left: var(--space-1); }
  .app-header__actions { flex: none; gap: 2px; }
  /* Present is its icon; the person is their photo (the name and full role are in the menu). */
  .app-header .present-toggle { --btn-h: var(--tap); }
  .identity { height: var(--tap); margin-left: 0; padding: 0 6px; }
  .identity__name, .identity__chevron { display: none; }
  .sunday-picker { max-width: 100%; padding: 2px; }
  .sunday-picker__step { --btn-h: 40px; }
  .sunday-picker__label { flex: 1 1 auto; min-width: 0; height: 40px; padding: 0 10px; }
  .sunday-picker--lg .sunday-picker__label { min-width: 0; }
  .popover--identity { min-width: min(300px, calc(100vw - 32px)); }

  .app-subnav__track { max-width: none; }
}

/* ---- Touch hit areas (tablet and phone) ----------------------------------------------------- */
@media (max-width: 1023px) {
  /* Tablets and phones held sideways are touch screens too. Small controls keep their look, and a
     centred, invisible ::before makes each one at least 44px tall to tap: buttons (phones also raise
     their default heights, --btn-h-*: tokens.css), chips, the header's brand and photo, the Sunday
     picker's date, the dashboard's campus switcher, "Clear", the ½ toggle and the sign-in flow's
     text links. */
  .chip, .q__clear, .rating__half, .identity, .app-header__brand, .campus-switch, .sunday-picker__label, .gate__switch { position: relative; }
  :is(.btn, .chip, .q__clear, .rating__half, .identity, .app-header__brand, .campus-switch, .sunday-picker__label, .gate__switch)::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: var(--tap);
    min-height: 100%;
    transform: translateY(-50%);
  }
  /* A toast's Undo and Dismiss: a 44px square at least, centred on the control. */
  .toast__action, .toast__close { position: relative; }
  .toast__action::before, .toast__close::before {
    content: "";
    position: absolute;
    left: 50%;
    right: auto;
    top: 50%;
    width: max(100%, var(--tap));
    height: var(--tap);
    min-height: 100%;
    transform: translate(-50%, -50%);
  }
}

/* ---- The calendar popover (Sunday pickers) on phones --------------------------------------- */
@media (max-width: 600px) {
  .popover--calendar .calendar { width: min(328px, calc(100vw - 32px)); padding: var(--space-3) var(--space-3) var(--space-2); }
  .popover--calendar .calendar__day { width: min(44px, 100%); height: 44px; font-size: var(--fs-14); }
  .popover--calendar .calendar__nav .btn { --btn-h: 44px; }
}

/* ---- Buttons ------------------------------------------------------------------------------- */
@media (max-width: 600px) {
  /* Footer button pairs share the width. */
  .btn-group { flex-wrap: wrap; }
}

/* ---- Form fields --------------------------------------------------------------------------- */
@media (max-width: 1023px) {
  /* 16px or larger below desktop (phones, tablets, a phone held sideways), so iOS doesn't zoom into
     a focused field. */
  :is(.input, .textarea, .select):not(.input--code) { font-size: max(16px, var(--fs-16)); }
  .input--code:placeholder-shown { font-size: max(16px, var(--fs-16)); }
  .textarea--reading, .textarea--serif { font-size: max(16px, var(--fs-comment)); }
  /* A full 44px to tap; the small ones keep their size on a tablet (phones raise them, below). */
  :is(.input, .select):not(.input--sm, .select--sm) { min-height: var(--tap); }
}
@media (max-width: 600px) {
  .input--sm, .select--sm { min-height: 40px; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .combobox__toggle { width: 40px; height: 40px; }
  .check, .switch { min-height: var(--tap); }
}

/* ---- Chips (wrap, never clip) ------------------------------------------------------------- */
@media (min-width: 601px) and (max-width: 1023px) {
  /* Tablet chips keep their 34px pill; rows sit 12px apart so each one’s 44px tap area is its own. */
  .chips { row-gap: 12px; }
}
@media (max-width: 600px) {
  /* A long label wraps inside its pill instead of running off the screen; the line box stays 1.3
     (never line-height: 1, docs/FRONTEND.md "Words never clip"). */
  .chip {
    min-height: 40px;
    padding: 7px 14px;
    white-space: normal;
    text-align: left;
    overflow-wrap: anywhere;
  }
  /* (Its 44px tap area: "Touch hit areas" above.) */
  .chips--sm .chip { min-height: 32px; padding: 5px 11px; }
  .chips--lg .chip { min-height: var(--tap); padding: 8px 18px; }
}

/* ---- Choice cards, segmented control, tabs ------------------------------------------------- */
@media (max-width: 600px) {
  /* Two across at most (data-cols comes from choiceCards({ columns })); one-column sets stay one. */
  .choice-cards:not([data-cols="1"]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choice-card { min-height: 96px; padding: var(--space-4); gap: 10px; }
  .choice-card__media { max-width: 100%; overflow: hidden; --logo-h: 18px; }
  .choice-card__media .logo img { max-width: 100%; height: auto; max-height: var(--logo-h); }
  .choice-card__check { top: 10px; right: 10px; }

  .segmented { max-width: 100%; }
  .segmented__option { position: relative; min-height: 38px; }
  .segmented__option::before { content: ""; position: absolute; left: 0; right: 0; top: -3px; bottom: -3px; }
  .segmented--sm .segmented__option { min-height: 32px; }
  .segmented--sm .segmented__option::before { top: 50%; bottom: auto; height: var(--tap); transform: translateY(-50%); }

  .tabs { gap: 22px; scroll-padding-inline: var(--space-4); }
  .tab { min-height: var(--tap); }
}

/* ---- Cards and section cards --------------------------------------------------------------- */
@media (max-width: 600px) {
  .card { padding: var(--space-4); }
  .card--flush { padding: 0; }
  .card--lg { padding: var(--space-5) var(--space-4); }
  .card__header { flex-wrap: wrap; gap: var(--space-2) var(--space-3); }
  .card__footer { flex-wrap: wrap; }

  .section-card { padding: var(--space-5) var(--space-4) var(--space-2); }
  /* The kicker drops under the title instead of squeezing it. */
  .section-card__head { grid-template-columns: auto minmax(0, 1fr); row-gap: var(--space-1); }
  .section-card__kicker { grid-column: 2; justify-self: start; text-align: left; padding-left: 0; }
  .section-card__intro { font-size: var(--fs-15); }

  .page-head { flex-direction: column; align-items: stretch; gap: var(--space-4); margin-bottom: var(--space-5); }
}

/* ---- Questions and the rating control ------------------------------------------------------ */
@media (max-width: 600px) {
  /* Label on top, the answer under it, full width. */
  .q { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-3); padding: var(--space-4) 0; }
  .q__control { flex-wrap: wrap; row-gap: var(--space-2); }
  /* "Clear" shows whenever there is an answer (no hover on a phone) and sits after the answer. */
  .q__control > .q__clear { order: 1; opacity: 1; min-height: var(--tap); padding: 0 4px; }
  .q__row { flex-wrap: wrap; }
  .q__row > .q__clear { opacity: 1; min-height: var(--tap); }

  /* 44px circles; the ½ toggle gets its own line under the row so five circles always fit 360px. */
  .rating:not(.rating--sm):not(.rating--readonly) { --rating-size: var(--tap); --rating-gap: 8px; column-gap: 0; }
  .rating:not(.rating--sm):not(.rating--readonly) .rating__opt { font-size: var(--fs-16); }
  .rating__half { grid-column: 1; grid-row: 3; justify-self: start; height: 36px; margin-top: var(--space-2); }

  .yesno__opt { height: var(--tap); min-width: 72px; }
  .yesno--readonly .yesno__opt { height: 34px; min-width: 64px; }
}

/* ---- Tables (scroll inside their card) ------------------------------------------------------ */
@media (max-width: 600px) {
  /* .table-wrap is the shared wrapper: it scrolls sideways inside its card. Give the table a floor
     with --table-min-w on the wrap (e.g. 640px) when its columns would otherwise squash. */
  .table-wrap { overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .table-wrap > .table { min-width: var(--table-min-w, 0); }
  .table th, .table td { padding: 10px 12px; }
  .table--compact th, .table--compact td { padding: 7px 10px; }
}

/* ---- Overlays: drawers and dialogs become full-screen sheets; menus, toasts ------------------ */
@media (max-width: 600px) {
  .drawer {
    left: 0;
    width: 100%;
    border-left: 0;
    animation-name: cp-sheet-in;
  }
  .drawer-root.is-closing .drawer { animation-name: cp-sheet-out; }
  .drawer__head { padding: var(--space-3) var(--space-4) var(--space-3); align-items: center; }
  .drawer__title { font-size: var(--fs-section); }
  .drawer__body { padding: var(--space-4) var(--space-4) var(--space-6); }
  .drawer__foot { flex-wrap: wrap; padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px)); }
  .drawer__foot > .btn { flex: 1 1 auto; }

  /* The one grid row is bounded by the screen, so a dialog taller than the screen scrolls its body
     and keeps its footer in reach. */
  .modal-root { padding: 0; place-items: stretch; overflow: hidden; grid-template-rows: minmax(0, 1fr); }
  .modal {
    width: 100%;
    height: 100%;
    max-height: none;
    border: 0;
    border-radius: 0;
    animation-name: cp-sheet-in;
  }
  .modal-root.is-closing .modal { animation-name: cp-sheet-out; }
  .modal__head { padding: var(--space-3) var(--space-4) 0; align-items: center; }
  .modal__body { flex: 1 1 auto; min-height: 0; padding: var(--space-3) var(--space-4) var(--space-4); }
  .modal__foot {
    flex-wrap: wrap;
    padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--hairline);
  }
  .modal__foot > .btn { flex: 1 1 0; }
  /* A short confirm or notice (size 'sm': confirmDialog and the like) is a sheet from the bottom
     instead: as tall as its words, its buttons in reach of a thumb. Bigger dialogs and editors stay
     full screen. (Two classes, so a page's own .modal height rules don't stretch it again.) */
  .modal.modal--sm {
    align-self: end;
    height: auto;
    max-height: calc(100% - var(--space-6));
    border-top: 1px solid var(--hairline);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .modal--sm .modal__head { padding-top: var(--space-4); }
  .modal--sm .modal__body { padding-bottom: var(--space-2); }
  .modal--sm .modal__foot { border-top: 0; }

  /* The close button: a clear 44px circle in the sheet's top corner. */
  .drawer__close, .modal__close {
    --btn-h: var(--tap);
    flex: none;
    margin: 0 -4px 0 0;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--hairline);
    color: var(--ink);
  }
  .drawer__close .icon, .modal__close .icon { --icon-size: 20px; }

  .menu__item { min-height: var(--tap); }
  .listbox__option { min-height: var(--tap); }
  .tooltip { max-width: calc(100vw - 32px); }

  .toast-region { left: var(--space-4); right: var(--space-4); transform: none; }
  .toast { max-width: 100%; }
}

/* ---- Empty states, callouts ----------------------------------------------------------------- */
@media (max-width: 600px) {
  .empty { padding: var(--space-6) var(--space-4); }
}

/* ---- Sign-in flow and "Where to?" ------------------------------------------------------------ */
@media (max-width: 600px) {
  .gate__title { font-size: calc(28px * var(--type-scale)); }
  /* The doors stack: one per row, shorter, the art beside nothing. */
  .doors--2, .doors--3 { grid-template-columns: minmax(0, 1fr); max-width: none; }
  .doors { gap: var(--space-3); margin-top: var(--space-6); }
  .where__title { margin-top: var(--space-5); font-size: calc(38px * var(--type-scale)); }
  .where__lede { font-size: var(--fs-16); }
  /* The photo keeps its desktop size (120px, lib/auth.js whereToView): a hero screen gets 112px or
     more (CLAUDE.md "Profile photos are big"), and it fits from 360px. */

  /* The flow's Back arrow: a 44px circle (the arrow stays where it was); "Not on the list?" and the
     other text links get their 44px tap area from "Touch hit areas" above. */
  .gate__back { --btn-h: var(--tap); top: 10px; left: 10px; }
}
@media (max-width: 1023px) {
  /* Three doors stack below desktop (two still sit side by side on a tablet). Stacked doors don't
     share rows. */
  .doors--3 { grid-template-columns: minmax(0, 1fr); max-width: 560px; gap: var(--space-4); }
  .doors--3 { grid-template-rows: none; }
  .doors--3 .door { display: flex; grid-row: auto; }
  .door { min-height: 0; padding: 26px 28px 22px; }
  .door__title { font-size: calc(28px * var(--type-scale)); max-width: none; }
}
@media (max-width: 600px) {
  .doors:not(.doors--1) { grid-template-rows: none; }
  .doors:not(.doors--1) .door { display: flex; grid-row: auto; }
  .door { padding: var(--space-5) var(--space-5) var(--space-4); }
  .door__art { height: 40px; margin-bottom: var(--space-4); }
  .door__title { font-size: calc(28px * var(--type-scale)); max-width: none; }
  .door__go { padding-top: var(--space-4); }
}

@keyframes cp-sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes cp-sheet-out { from { transform: none; opacity: 1; } to { transform: translateY(24px); opacity: 0; } }
