/*
  views.css — cards, forms, tables, badges and the per-view layout pieces.

  Same rules as shell.css: hand-written, tokens only, no framework. State is
  never communicated by colour alone (spec §10) — every badge carries a word,
  and every error is text next to the field it belongs to.
*/

/* --------------------------------------------------------------- structure */

.c-card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-card);
}

@media (min-width: 640px) {
  .c-card {
    padding: var(--space-5);
  }
}

.c-card__title {
  font-family: var(--font-display-stack);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.012em;
  margin: 0 0 var(--space-3);
}

.c-card--flush {
  padding: 0;
  overflow: hidden;
}

.c-stack > * + * {
  margin-top: var(--space-3);
}

.c-row {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
}

.c-row--between {
  justify-content: space-between;
}

.c-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .c-grid--2 {
    grid-template-columns: 1fr 1fr;
  }
}

/* --------------------------------------------------------------- headings */

.c-page-head {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--c-line);
}

/* A short brass rule sits on the hairline: a quiet, brand-led section mark. */
.c-page-head::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 3rem;
  height: 2px;
  background: var(--c-accent);
}

.c-page-head h1 {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  line-height: 1.1;
}

/* --------------------------------------------------------------- details */

.c-details {
  margin: 0;
  display: grid;
  gap: var(--space-3);
}

.c-details__row {
  display: grid;
  gap: var(--space-1);
}

.c-details dt {
  color: var(--c-ink-muted);
  font-size: var(--font-small);
  font-weight: 600;
}

.c-details dd {
  margin: 0;
  font-size: var(--font-lead);
}

@media (min-width: 640px) {
  .c-details--split {
    grid-template-columns: 1fr 1fr;
  }
}

/* --------------------------------------------------------------- badges */

/* A badge is text plus a tint. Remove the colour and it still means something. */
.c-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid var(--c-border);
  background: var(--c-bg-sunk);
  color: var(--c-ink);
}

/* A dot carries the tone as well as the word, without relying on colour
   alone — the label remains the primary signal. */
.c-badge::before {
  content: "";
  flex: none;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

.c-badge--ok {
  background: var(--c-ok-bg);
  color: var(--c-ok-ink);
  border-color: var(--c-ok-border);
}

.c-badge--warn {
  background: var(--c-warn-bg);
  color: var(--c-warn-ink);
  border-color: var(--c-warn-border);
}

.c-badge--danger {
  background: var(--c-danger-bg);
  color: var(--c-danger-ink);
  border-color: var(--c-danger-border);
}

/* --------------------------------------------------------------- forms */

.c-field {
  margin-bottom: var(--space-4);
  max-width: 32rem;
}

.c-field label {
  display: block;
  font-size: var(--font-small);
  font-weight: 600;
  letter-spacing: 0.01em;
  margin-bottom: var(--space-2);
}

.c-field input,
.c-field select,
.c-field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  font: inherit;
  font-size: var(--font-body); /* >=16px stops iOS zooming on focus */
  color: var(--c-ink);
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-control);
  box-shadow: inset 0 1px 1px rgba(53, 44, 28, 0.04);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.c-field input:focus-visible,
.c-field select:focus-visible,
.c-field textarea:focus-visible {
  border-color: var(--c-focus);
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.c-field input[aria-invalid="true"] {
  border-color: var(--c-danger-border);
  background: var(--c-danger-bg);
}

/* Checkbox rows: the label sits beside the box, so it must not be forced onto
   its own line by the block label rule above. */
.c-field--check label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 400;
  min-height: var(--tap);
}

.c-field--check input[type="checkbox"] {
  width: 1.5rem;
  height: 1.5rem;
  min-height: 0;
  flex: 0 0 auto;
}

.c-field__hint {
  color: var(--c-ink-muted);
  font-size: var(--font-small);
  margin-top: var(--space-1);
}

/* Live subdomain checker result. Colour is never the only signal: the copy
   says "Available" or explains why not. */
.c-field__hint--ok {
  color: var(--c-ok-ink);
  font-weight: 600;
}

.c-field__hint--error {
  color: var(--c-danger-ink);
  font-weight: 600;
}

/* Live club-address preview shown under the club name: the full host is the
   thing the founder is choosing, so it gets its own line rather than a quiet
   hint. */
.c-urlpreview {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--c-bg-sunk);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-sm);
  color: var(--c-ink-muted);
  font-size: var(--font-small);
  overflow-wrap: anywhere;
}

.c-urlpreview strong {
  color: var(--c-ink);
  font-weight: 600;
}

.c-field__error {
  color: var(--c-danger-ink);
  font-size: var(--font-small);
  font-weight: 600;
  margin-top: var(--space-1);
}

/* Form-level error: bordered, labelled, and announced. */
.c-formerror {
  background: var(--c-danger-bg);
  color: var(--c-danger-ink);
  border: 1px solid var(--c-danger-border);
  border-radius: var(--radius);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  font-weight: 600;
}

.c-formactions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
}

/* --------------------------------------------------------------- auth card */

.c-auth {
  max-width: 26rem;
  margin: var(--space-6) auto;
}

.c-auth h1 {
  font-size: var(--font-title);
}

/* --------------------------------------------------------------- tables */

/* Tables scroll rather than squash on a phone. */
.c-tablewrap {
  overflow-x: auto;
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  background: var(--c-surface);
}

.c-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-small);
}

.c-table caption {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  color: var(--c-ink-muted);
  font-size: var(--font-small);
}

.c-table th,
.c-table td {
  text-align: left;
  padding: 0.875rem var(--space-4);
  border-bottom: 1px solid var(--c-line);
  vertical-align: middle;
}

.c-table th {
  background: transparent;
  color: var(--c-ink-muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.c-table tbody tr:hover td {
  background: var(--c-bg-sunk);
}

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

.c-table td .c-btn {
  min-height: var(--tap);
}

/* --------------------------------------------------------------- lists */

.c-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.c-list__item {
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--c-line);
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.c-list__item:last-child {
  border-bottom: 0;
}

/* --------------------------------------------------------------- misc */

.c-empty {
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  background: var(--c-surface);
  box-shadow: var(--shadow-card);
  padding: var(--space-6) var(--space-5);
  text-align: center;
  color: var(--c-ink-muted);
}

/* The install help sheet shown on iOS, where there is no install prompt. */
.c-sheet {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-bg-sunk);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.c-sheet ol {
  margin: 0;
  padding-left: var(--space-5);
}

.c-sheet li {
  margin-bottom: var(--space-2);
}

.c-money {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* --------------------------------------------------------------- state cards */

/* A card that needs attention. The word in the title carries the meaning; the
   edge is reinforcement, not the message. */
.c-card--warn {
  border-left: 4px solid var(--c-warn-border);
  background: var(--c-warn-bg);
}

.c-card--ok {
  border-left: 4px solid var(--c-ok-border);
  background: var(--c-ok-bg);
}

.c-card__title--flush {
  margin: 0;
}

/* --------------------------------------------------------------- lists */

.c-list__item--unread {
  background: color-mix(in srgb, var(--c-accent) 10%, transparent);
  box-shadow: inset 3px 0 0 var(--c-accent);
  margin-inline: calc(var(--space-3) * -1);
  padding-inline: var(--space-3);
}

.c-list__item--stacked {
  align-items: stretch;
  flex-direction: column;
}

.c-list__item--stacked > * {
  min-width: 0;
}

.c-menulink {
  display: block;
  width: 100%;
  color: inherit;
  text-decoration: none;
  padding: var(--space-2);
  margin: calc(var(--space-2) * -1);
  border-radius: var(--radius-sm);
}

.c-menulink:hover {
  background: var(--c-bg-sunk);
}

.c-menulink strong {
  display: block;
}

.c-prose {
  margin: 0;
  padding-left: 1.25rem;
  display: grid;
  gap: var(--space-2);
  color: var(--c-ink);
  line-height: 1.45;
}

.c-prose li::marker {
  color: var(--c-ink-muted);
}

.c-menulink .c-hint {
  display: block;
}

/* --------------------------------------------------------------- messages
   Scoped to .c-chat. Theme-aware: warm paper and hunter-green outgoing
   bubbles in light; the original green-black room in dark. Brass accents and
   a fluid composer in both, for every member including the Guest desk. */

.c-chat {
  /* Theme-aware messaging. Light: warm paper, white panels, hunter-green
     outgoing bubbles, brass accents. Dark: the original green-black room. */
  --msg-bg: var(--c-bg-sunk);
  --msg-surface: var(--c-surface);
  --msg-bubble: var(--c-bg-sunk);
  --msg-elevated: var(--c-bg-sunk);
  --msg-border: var(--c-border);
  --msg-text: var(--c-ink);
  --msg-muted: var(--c-ink-muted);
  --msg-gold: var(--c-link);
  --msg-reaction: var(--c-bg-sunk);
  --msg-ink: var(--c-surface);
  --msg-avatar-bg: var(--c-brand-soft);
  --msg-avatar-ink: var(--c-brand);
  --msg-avatar-border: var(--c-line);
  --msg-active-bg: color-mix(in srgb, var(--c-accent) 13%, transparent);
  --msg-active-bar: var(--c-accent);
  --msg-mine-bg: var(--c-brand);
  --msg-mine-ink: var(--c-on-brand);
  --msg-mine-muted: color-mix(in srgb, var(--c-on-brand) 74%, transparent);
  --msg-mine-border: var(--c-brand);
  --msg-send-bg: var(--c-brand);
  --msg-send-ink: var(--c-on-brand);
  --msg-send-hover: var(--c-brand-dark);
  --msg-shadow: 0 1px 2px rgba(53, 44, 28, 0.05),
    0 18px 40px -30px rgba(53, 44, 28, 0.35);
  --msg-radius-bar: 16px;
  --msg-radius-send: 12px;
  --msg-radius-pill: 10px;

  display: grid;
  grid-template-columns: minmax(18rem, 22rem) minmax(0, 1fr);
  gap: var(--space-5);
  align-items: stretch;
  min-height: 0;
  color: var(--msg-text);
}

html[data-theme="dark"] .c-chat {
  --msg-bg: #0a0c0a;
  --msg-surface: #161a16;
  --msg-bubble: #161a16;
  --msg-elevated: #1c221c;
  --msg-border: #2a322a;
  --msg-text: #f2f4f2;
  --msg-muted: #a8b0a8;
  --msg-gold: #e0b84a;
  --msg-reaction: #1e241e;
  --msg-ink: #0a0c0a;
  --msg-avatar-bg: #1c221c;
  --msg-avatar-ink: #e0b84a;
  --msg-avatar-border: color-mix(in srgb, #2a322a 50%, transparent);
  --msg-active-bg: #1c221c;
  --msg-active-bar: #e0b84a;
  --msg-mine-bg: #1c221c;
  --msg-mine-ink: #f2f4f2;
  --msg-mine-muted: #a8b0a8;
  --msg-mine-border: color-mix(in srgb, #e0b84a 28%, transparent);
  --msg-send-bg: #e0b84a;
  --msg-send-ink: #0a0c0a;
  --msg-send-hover: #c9a227;
  --msg-shadow: 0 1px 2px rgba(0, 0, 0, 0.2),
    0 18px 40px -26px rgba(0, 0, 0, 0.7);
}

.c-messages {
  list-style: none;
  margin: 0 0 var(--space-3);
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.c-message {
  display: grid;
  gap: 0.15rem;
  max-width: min(42rem, 88%);
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.c-message--mine {
  margin-left: auto;
  justify-items: end;
}

.c-message__head {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  min-width: 0;
  max-width: 100%;
}

.c-message--mine .c-message__head {
  flex-direction: row-reverse;
}

/* Bubble and its kebab share a row; outgoing messages put the kebab on the
   left so it never crowds the right edge of the phone viewport. */
.c-message__row {
  display: flex;
  align-items: flex-end;
  gap: 0.15rem;
  max-width: 100%;
  min-width: 0;
}

.c-message--mine .c-message__row {
  flex-direction: row-reverse;
}

/* Slim bubbles: tight padding and a shallow radius keep more messages above
   the fold, which matters most on a phone. */
.c-message__bubble {
  border: 1px solid var(--msg-border);
  border-radius: 3px 10px 10px 10px;
  background: var(--msg-bubble);
  padding: 0.4rem 0.65rem;
  box-shadow: none;
  max-width: 100%;
  min-width: 0;
}

/* Outgoing runs green in light (club livery), elevated dark green in dark. */
.c-message--mine .c-message__bubble {
  background: var(--msg-mine-bg);
  border-color: var(--msg-mine-border);
  border-radius: 10px 3px 10px 10px;
  color: var(--msg-mine-ink);
  box-shadow: none;
}

/* Queued offline send (Slice C) — still visible, clearly not delivered yet. */
.c-message--pending .c-message__bubble,
.c-message__bubble--pending {
  opacity: 0.72;
}

.c-message--mine .c-message__body,
.c-message--mine .c-message__meta strong {
  color: var(--msg-mine-ink);
}

.c-message--mine .c-message__meta {
  color: var(--msg-mine-muted);
}

/* Links and inline buttons inside an outgoing bubble sit on hunter green, so
   they take the bubble ink rather than the page link colour. */
.c-message--mine .c-message__bubble a,
.c-message--mine .c-message__bubble .c-linkbtn {
  color: var(--msg-mine-ink);
  text-decoration-color: color-mix(in srgb, var(--msg-mine-ink) 60%, transparent);
}

.c-message__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 0.4rem;
  align-items: baseline;
  color: var(--msg-muted);
  font-size: 11px;
  line-height: 14px;
  font-weight: 400;
  min-width: 0;
}

.c-message__meta strong {
  color: var(--msg-text);
  font-weight: 600;
  font-size: 12px;
}

.c-message__body {
  margin: 0;
  color: var(--msg-text);
  font-size: 15px;
  font-weight: 400;
  line-height: 19px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.c-message__bubble .c-list {
  margin-top: 0.5rem;
}

.c-reaction__who {
  width: 100%;
  margin: 0;
}

.c-message__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.6rem;
  align-items: center;
  min-height: 0;
}

.c-message__actions .c-btn,
.c-message__actions .c-linkbtn {
  min-height: 28px;
  padding-block: 0.1rem;
  color: var(--msg-muted);
  font-size: 12px;
  font-weight: 500;
}

.c-message__actions .c-linkbtn:hover {
  color: var(--msg-gold);
}

/* --------------------------------------------------------------- kebab menu */

.c-msgmenu {
  position: relative;
  flex: none;
  align-self: flex-end;
}

.c-msgmenu__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--msg-muted);
  font-size: 18px;
  line-height: 1;
  letter-spacing: 0.05em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.c-msgmenu__trigger:hover,
.c-msgmenu__trigger:focus-visible,
.c-msgmenu__trigger[aria-expanded="true"] {
  background: var(--msg-elevated);
  color: var(--msg-text);
}

.c-msgmenu__list {
  position: absolute;
  z-index: 40;
  top: calc(100% - 4px);
  right: 0;
  min-width: 8.5rem;
  padding: 4px;
  display: grid;
  gap: 2px;
  background: var(--msg-surface);
  border: 1px solid var(--msg-border);
  border-radius: 10px;
  box-shadow: var(--msg-shadow);
}

.c-msgmenu__list[hidden] {
  display: none;
}

.c-msgmenu__item {
  display: block;
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--msg-text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.c-msgmenu__item:hover,
.c-msgmenu__item:focus-visible {
  background: var(--msg-elevated);
}

/* --------------------------------------------------------------- reactions */

.c-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin: 0 0 0.2rem;
}

.c-message--mine .c-reactions {
  justify-content: flex-end;
}

.c-reaction {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 34px;
  min-height: 26px;
  padding: 0 0.45rem;
  border: 1px solid transparent;
  border-radius: var(--msg-radius-pill);
  background: var(--msg-reaction);
  color: var(--msg-text);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.c-reaction__count {
  color: var(--msg-muted);
  font-size: 11px;
  font-weight: 500;
}

.c-reaction:hover {
  background: var(--msg-elevated);
  border-color: color-mix(in srgb, var(--msg-gold) 30%, transparent);
}

.c-reaction--mine {
  border-color: var(--msg-gold);
  transform: scale(1.02);
}

.c-reactions__add {
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.c-reactions--picking .c-reactions__add {
  display: flex;
}

.c-reaction--toggle {
  opacity: 0.75;
  border-style: dashed;
  border-color: color-mix(in srgb, var(--msg-border) 80%, transparent);
}

.c-reactions--picking .c-reaction--toggle,
.c-reaction--toggle[aria-expanded="true"] {
  opacity: 1;
  border-style: solid;
  border-color: var(--msg-gold);
}

.c-reaction--add {
  opacity: 0.95;
}

.c-reaction--more {
  color: var(--msg-muted);
  font-size: 12px;
  font-weight: 600;
}

/* --------------------------------------------------------------- chat shell */

.c-chat__sidebar {
  border: 1px solid var(--msg-border);
  border-radius: var(--radius);
  background: var(--msg-surface);
  box-shadow: var(--msg-shadow);
  overflow: hidden auto;
  max-height: calc(100dvh - 7rem);
  position: sticky;
  top: var(--space-4);
}

.c-chat__pane {
  min-width: 0;
  display: grid;
  gap: var(--space-3);
  align-content: start;
  padding: 0;
}

.c-chat__pane > .c-page-head {
  margin-bottom: 0;
}

.c-chat__pane > .c-card,
.c-chat__create > .c-card {
  margin-bottom: 0;
  background: var(--msg-surface);
  border-color: var(--msg-border);
  border-radius: var(--radius);
}

.c-chat__section {
  border-bottom: 1px solid var(--msg-border);
}

.c-chat__section:last-child {
  border-bottom: 0;
}

.c-chat__summary {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--space-2);
  align-items: center;
  padding: 0.75rem 1rem;
  background: transparent;
  color: var(--msg-muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
}

.c-chat__summary::-webkit-details-marker {
  display: none;
}

.c-chat__summary::after {
  content: '▾';
  color: var(--msg-muted);
}

.c-chat__section:not([open]) > .c-chat__summary::after {
  content: '▸';
}

.c-chat__section[open] > .c-chat__summary {
  border-bottom: 1px solid var(--msg-border);
}

.c-chat__sectioncount {
  color: var(--msg-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

.c-chat__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.c-chat__entry {
  border-bottom: 1px solid color-mix(in srgb, var(--msg-border) 60%, transparent);
}

.c-chat__entry:last-child {
  border-bottom: 0;
}

.c-chat__item,
.c-chat__member {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  min-height: 44px;
  transition: background 120ms ease;
}

.c-chat__item:hover,
.c-chat__member:hover {
  background: var(--msg-elevated);
}

.c-chat__item--active {
  background: var(--msg-active-bg);
  box-shadow: inset 3px 0 0 var(--msg-active-bar);
}

.c-chat__item--unread .c-chat__name {
  font-weight: 700;
  color: var(--msg-text);
}

.c-chat__avatar {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  object-fit: cover;
  background: var(--msg-avatar-bg);
  color: var(--msg-avatar-ink);
  border: 1px solid var(--msg-avatar-border);
  font-size: 12px;
  font-weight: 700;
}

.c-chat__avatar--sm {
  width: 1.75rem;
  height: 1.75rem;
}

.c-chat__lines {
  display: grid;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}

.c-chat__top,
.c-chat__bottom {
  display: flex;
  gap: var(--space-2);
  align-items: baseline;
  justify-content: space-between;
  min-width: 0;
}

.c-chat__name {
  overflow: hidden;
  color: var(--msg-text);
  font-weight: 600;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.c-chat__time {
  flex: 0 0 auto;
  color: var(--msg-muted);
  font-size: 12px;
  line-height: 16px;
}

.c-chat__preview {
  overflow: hidden;
  color: var(--msg-muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.c-chat__unread {
  flex: 0 0 auto;
  min-width: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--msg-gold);
  color: var(--msg-ink);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.c-chat__hint {
  margin: 0;
  padding: 0.75rem 1rem;
  color: var(--msg-muted);
  font-size: 13px;
}

.c-chat__label {
  margin: 0;
  padding: 0.75rem 1rem 0.25rem;
  color: var(--msg-muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.c-chat__search {
  width: calc(100% - 2rem);
  margin: 0 1rem 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--msg-border);
  border-radius: var(--radius-control);
  background: var(--msg-bg);
  color: var(--msg-text);
  font: inherit;
  font-size: 15px;
}

.c-chat__search:focus-visible {
  border-color: var(--msg-gold);
  outline: 2px solid var(--msg-gold);
  outline-offset: 1px;
}

.c-chat__search::placeholder {
  color: var(--msg-muted);
}

.c-chat__list--members {
  max-height: 15rem;
  overflow-y: auto;
}

.c-chat__create {
  border: 1px solid var(--msg-border);
  border-radius: var(--radius);
  background: var(--msg-surface);
  overflow: hidden;
}

.c-chat__create > .c-card {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.c-chat__messages {
  max-height: 55vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 0.25rem 0.25rem 0.5rem 0;
  background: transparent;
}

/* Phone-only escape hatch from a long feed: appears once the page header (and
   its "All conversations" link) has scrolled out of reach. */
.c-chat__back {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 0.6rem);
  left: 0.6rem;
  z-index: 30;
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--msg-border);
  border-radius: 50%;
  background: color-mix(in srgb, var(--msg-surface) 94%, transparent);
  color: var(--msg-text);
  box-shadow: var(--msg-shadow);
  backdrop-filter: blur(6px);
  text-decoration: none;
}

.c-chat__back:hover,
.c-chat__back:focus-visible {
  border-color: var(--msg-gold);
  color: var(--msg-gold);
}

.c-chat__jump {
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 5.5rem);
  z-index: 3;
  display: block;
  width: max-content;
  margin: 0 auto 0.5rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--msg-border) 40%, transparent);
  border-radius: 999px;
  background: var(--msg-surface);
  color: var(--msg-text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgb(0 0 0 / 15%);
  cursor: pointer;
}

.c-chat__jump:hover {
  background: var(--msg-elevated);
  color: var(--msg-gold);
  border-color: color-mix(in srgb, var(--msg-gold) 40%, transparent);
}

@media (min-width: 1024px) {
  .c-chat__jump {
    bottom: var(--space-2);
  }
}

.c-thread__earlier {
  list-style: none;
  text-align: center;
  padding-bottom: var(--space-2);
}

.c-date,
.c-chat__new {
  list-style: none;
  display: flex;
  justify-content: center;
  padding: 0.35rem 0;
}

.c-date span,
.c-chat__new span {
  padding: 0.15rem 0.7rem;
  border: 1px solid var(--msg-border);
  border-radius: 999px;
  background: var(--msg-surface);
  color: var(--msg-muted);
  font-size: 12px;
  line-height: 16px;
}

.c-chat__new span {
  color: var(--msg-gold);
  font-weight: 600;
}

/* --------------------------------------------------------- message composer */

.c-chat__composer {
  position: sticky;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 5;
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 8px 12px;
  min-height: 52px;
  border: 1px solid var(--msg-border);
  border-radius: var(--msg-radius-bar);
  background: var(--msg-surface);
  box-shadow: var(--msg-shadow);
  transition: box-shadow 150ms ease-out, border-color 150ms ease-out;
}

.c-chat__composer:focus-within {
  border-color: var(--msg-gold);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--msg-gold) 22%, transparent),
    var(--msg-shadow);
}

.c-composer__row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.c-composer__row textarea {
  flex: 1 1 auto;
  min-height: 36px;
  max-height: 120px;
  resize: none;
  padding: 8px 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--msg-text);
  caret-color: var(--msg-gold);
  font: inherit;
  font-size: 16px; /* stops iOS zooming the composer on focus */
  font-weight: 400;
  line-height: 22px;
  transition: height 200ms ease;
}

.c-composer__row textarea::placeholder {
  color: var(--msg-muted);
}

.c-composer__row textarea:focus,
.c-composer__row textarea:focus-visible {
  outline: none;
  box-shadow: 0 8px 16px -10px color-mix(in srgb, var(--msg-gold) 45%, transparent);
}

.c-composer__icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--msg-muted);
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease;
}

.c-composer__icon svg {
  display: block;
  width: 20px;
  height: 20px;
}

.c-composer__icon:hover,
.c-composer__icon[aria-expanded="true"] {
  color: var(--msg-gold);
  background: var(--msg-elevated);
}

.c-composer__send {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 72px;
  min-height: 36px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--msg-radius-send);
  background: var(--msg-send-bg);
  color: var(--msg-send-ink);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, transform 80ms ease;
}

.c-composer__send svg {
  display: block;
  width: 16px;
  height: 16px;
}

.c-composer__send:hover:not(:disabled) {
  background: var(--msg-send-hover);
  transform: translateY(-1px);
}

.c-composer__send:active:not(:disabled) {
  transform: scale(0.96);
}

.c-composer__send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.c-composer__emojis {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 6px;
  border: 0;
  border-radius: 12px;
  background: var(--msg-surface);
  box-shadow: var(--msg-shadow);
  animation: msg-emoji-in 180ms ease;
}

@keyframes msg-emoji-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .c-composer__emojis,
  .c-composer__send,
  .c-composer__icon,
  .c-reaction,
  .c-composer__row textarea {
    animation: none;
    transition: none;
  }
}

.c-composer__emojis[hidden] {
  display: none;
}

.c-composer__emoji {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--msg-radius-pill);
  background: var(--msg-reaction);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.c-composer__emoji:hover {
  background: var(--msg-elevated);
  border-color: color-mix(in srgb, var(--msg-gold) 30%, transparent);
}

.c-composer__emoji:active {
  border-color: var(--msg-gold);
  transform: scale(1.05);
}

.c-composer__file {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  color: var(--msg-muted);
  font-size: 12px;
}

.c-composer__file[hidden] {
  display: none;
}

.c-composer__more {
  border-top: 1px solid color-mix(in srgb, var(--msg-border) 40%, transparent);
  padding-top: 6px;
}

.c-composer__more-summary {
  color: var(--msg-muted);
  font-size: 12px;
  cursor: pointer;
}

.c-composer__more select {
  width: 100%;
  margin-top: 6px;
  background: var(--msg-bg);
  color: var(--msg-text);
  border: 1px solid var(--msg-border);
  border-radius: var(--radius-control);
}

/* Conversation view: use the full column height on desktop. The message card
   becomes the scrolling body between the header and a static composer, so the
   room reads as one surface rather than a stack of boxes. */
@media (min-width: 801px) {
  .c-chat--conversation {
    align-items: stretch;
  }

  .c-chat__pane--conversation {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    height: calc(100dvh - 9rem);
    min-height: 32rem;
  }

  .c-chat__pane--conversation > .c-card:first-of-type {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
    overflow: hidden;
  }

  .c-chat__pane--conversation > .c-card:first-of-type > .c-hint {
    margin: 0;
    padding: var(--space-3) var(--space-5) 0;
  }

  .c-chat__pane--conversation .c-chat__messages {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    padding: var(--space-4) var(--space-5) var(--space-5);
  }

  .c-chat__pane--conversation .c-chat__composer {
    position: static;
    margin-top: var(--space-1);
  }

  .c-chat__pane--conversation .c-chat__jump {
    bottom: var(--space-3);
  }
}

@media (max-width: 800px) {
  .c-chat {
    grid-template-columns: minmax(0, 1fr);
  }

  .c-chat__sidebar {
    position: static;
    max-height: none;
  }

  .c-chat--index .c-chat__pane,
  .c-chat--conversation .c-chat__sidebar {
    display: none;
  }

  /* The thread keeps its own scroll region on a phone. Unbound it grows with
     the page: a long conversation has no scrollable feed and the composer is
     pushed below the fold. dvh follows the browser chrome as it collapses. */
  .c-chat__messages {
    max-height: 60vh;
    min-height: 12rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0 0 var(--space-2);
  }

  @supports (height: 1dvh) {
    .c-chat__messages {
      max-height: 60dvh;
    }
  }

  .c-chat__composer {
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .c-chat--conversation .c-chat__back.is-visible {
    display: inline-flex;
  }
}

/* --------------------------------------------------------------- help tips */

.c-helptip {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  margin: 0 0 var(--space-3);
  max-width: 40rem;
}

.c-helptip__summary {
  cursor: pointer;
  list-style: none;
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.c-helptip__summary::-webkit-details-marker {
  display: none;
}

.c-helptip__summary::before {
  content: '?';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 1.35rem;
  block-size: 1.35rem;
  border-radius: 999px;
  border: 1px solid var(--c-border);
  font-size: 0.8rem;
  font-weight: 700;
  flex: 0 0 auto;
}

.c-helptip__summary::after {
  content: '';
  margin-inline-start: auto;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  inline-size: 0.4rem;
  block-size: 0.4rem;
  transform: rotate(45deg);
  opacity: 0.6;
}

.c-helptip[open] > .c-helptip__summary::after {
  transform: rotate(-135deg);
}

.c-helptip__body {
  padding: 0 var(--space-4) var(--space-3);
  color: var(--c-muted, inherit);
}

.c-helptip__body > p {
  margin: 0 0 var(--space-2);
}

.c-helptip__body > p:last-child {
  margin-bottom: 0;
}

.c-helptip__body ul {
  margin: 0 0 var(--space-2);
  padding-inline-start: 1.2rem;
}

.c-helptip__body li + li {
  margin-top: var(--space-1);
}

/* --------------------------------------------------------------- check grids */

.c-fieldset {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--space-3);
  margin: 0 0 var(--space-4);
  max-width: 32rem;
}

.c-fieldset legend {
  padding: 0 var(--space-2);
  font-weight: 600;
}

.c-checkgrid {
  display: grid;
  gap: var(--space-1);
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .c-checkgrid {
    grid-template-columns: 1fr 1fr;
  }
}

.c-checkrow {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
}

.c-checkrow input[type="checkbox"] {
  width: 1.5rem;
  height: 1.5rem;
  flex: 0 0 auto;
}

/* --------------------------------------------------------------- links */

.c-linkbtn {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0;
  border: 0;
  background: none;
  color: var(--c-brand);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.c-linkbox {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-3);
  border: 1px dashed var(--c-border);
  border-radius: var(--radius);
  background: var(--c-bg-sunk);
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------- QR codes */

.c-qr {
  display: block;
  width: 100%;
  max-width: 18rem;
  height: auto;
  background: #ffffff; /* the quiet zone must stay light for cameras */
  padding: var(--space-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
}

.c-qr-sheet {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  text-align: center;
}

.c-qr-sheet__code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--font-display);
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
  margin: 0;
}

/* --------------------------------------------------------------- scanner */

.c-scanner-wrap {
  position: relative;
  max-width: 30rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #000000;
}

.c-scanner {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

.c-scanner__zoom {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  display: flex;
  gap: 0.4rem;
  z-index: 1;
}

.c-scanner__zoombtn {
  inline-size: 2.75rem;
  block-size: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  border-radius: 999px;
  font-size: 1.35rem;
  line-height: 1;
  background: color-mix(in srgb, #000 55%, transparent);
  border-color: color-mix(in srgb, #fff 35%, transparent);
  color: #fff;
}

.c-scanner__zoombtn:hover:not(:disabled) {
  background: color-mix(in srgb, #000 70%, transparent);
}

.c-scanner__zoombtn[hidden],
.c-scanner__zoomhint[hidden] {
  display: none;
}

.c-scanner__zoomhint {
  margin: 0.5rem 0 0;
}

/* --------------------------------------------------------------- steps */

.c-steps {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-5);
}

.c-steps li {
  margin-bottom: var(--space-2);
}

/* --------------------------------------------------------------- progress */

.c-progress {
  width: 100%;
  max-width: 32rem;
  height: var(--space-4);
  accent-color: var(--c-brand);
}

/* --------------------------------------------------------------- misc */

.c-detail-code {
  font-size: var(--font-small);
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------- modal */

.c-modal__scrim {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgb(0 0 0 / 55%);
}

.c-modal__panel {
  width: min(28rem, 100%);
  max-height: calc(100vh - 2 * var(--space-4));
  overflow-y: auto;
  margin: 0;
}

.c-modal__panel--wide {
  width: min(36rem, 100%);
}

.c-qualreview__preview {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

.c-qualreview__img {
  display: block;
  width: 100%;
  max-height: 22rem;
  object-fit: contain;
  border-radius: var(--radius-md);
  border: 1px solid var(--c-line);
  background: var(--c-bg-sunk);
}

.c-setuplist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}

.c-setupstep {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-md);
  background: var(--c-bg);
}

.c-setupstep--done {
  opacity: 0.75;
  background: var(--c-bg-sunk);
}

/* ---------------------------------------------------- brand layer 2026
   Inline text links use --c-link (brass ink on paper, pale gold on dark)
   because raw brand green is a surface colour. The QR quiet zone and scanner
   backdrop below stay black/white on purpose: cameras need a light quiet zone
   and a dark field. */

.c-linkbtn {
  color: var(--c-link);
}

.c-linkbtn:hover {
  color: var(--c-link-hover);
}

/* ---------------------------------------------------------- profile photos */

.c-photo {
  display: grid;
  gap: var(--space-3);
}

.c-photo__preview {
  width: 7.5rem;
  height: 7.5rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--c-bg);
  border: 1px solid var(--c-line);
}

.c-photo__preview--logo {
  width: 10rem;
  height: 4.5rem;
  background: var(--c-bg-sunk);
}

.c-photo__preview--logo .c-photo__img {
  object-fit: contain;
  padding: var(--space-2);
}

.c-photo__img,
.c-photo__video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.c-photo__video {
  width: min(100%, 22rem);
  height: auto;
  max-height: 16rem;
  border-radius: var(--radius-md);
  background: #000;
}

.c-photo__placeholder {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--c-muted);
  font-size: var(--font-small, 0.875rem);
  text-align: center;
  padding: var(--space-2);
}

.c-photo__camera {
  display: grid;
  gap: var(--space-2);
}

/* Member directory portrait beside the name. */
.c-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  background: var(--c-bg);
  border: 1px solid var(--c-line);
}

.c-avatar--empty {
  display: inline-block;
  background: var(--c-brand-soft);
}

/* Register: portrait beside the name for welcoming guests. */
.c-person {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.c-person__photo {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  background: var(--c-bg);
  border: 1px solid var(--c-line);
}

.c-person__photo--empty {
  background: var(--c-brand-soft);
}

/* -------------------------------------------------- Section 21 declaration */

.c-prose {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  white-space: pre-wrap;
}

.c-declaration {
  padding: var(--space-3);
  border-left: 3px solid var(--c-brand);
  background: var(--c-brand-soft);
  font-weight: 600;
}

.c-pdfpreview {
  width: 100%;
  min-height: 28rem;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-md);
  background: #fff;
}

.c-importmap {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--c-line);
}

.c-importmap:last-of-type {
  border-bottom: 0;
}

.c-importmap__target {
  display: grid;
  gap: var(--space-1);
}

@media (min-width: 48rem) {
  .c-importmap {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    align-items: start;
    gap: var(--space-4);
  }
}

.c-signbox {
  margin-top: var(--space-3);
  padding: var(--space-4);
  border: 2px dashed var(--c-line);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
}

.c-signpad {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.c-signpad__canvas {
  width: 100%;
  max-width: 35rem;
  height: auto;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-md);
  background: #fff;
  touch-action: none;
}

.c-signpad__preview {
  display: block;
  max-width: 16rem;
  max-height: 5rem;
  margin: var(--space-2) auto 0;
  background: #fff;
  border: 1px solid var(--c-line);
}

.c-fieldset--radio {
  margin: 0;
  padding: 0;
  border: 0;
}

.c-fieldset--radio legend {
  padding: 0;
  margin: 0 0 var(--space-2);
  font-weight: 600;
}

.c-row--radios {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.c-field--radio {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  cursor: pointer;
}
