/* Collab pages: /collab (the form), /collab-status (the applicant's status), /collab-admin (the team's desk).
   Built on the design system (docs/design/DESIGN.md): qz-* classes for type, bands, buttons and the CRT; cb-* here for the form, the card and the desk.
   Tokens only, light only. Hover is gated to a real pointer; motion is transform and opacity, short, and off for reduced motion. */

/* Hero: copy on the left, the CRT on the right. DOM order is the reading order, so the copy leads at every width. */
.cb-hero { display: grid; gap: var(--space-8); align-items: center; }
.cb-copy { display: grid; gap: var(--space-4); justify-items: start; }
.cb-copy .qz-btn { margin-block-start: var(--space-2); }
.cb-crt { --crt-size: var(--text-lead-size); min-width: 0; padding: var(--space-6) var(--space-8); }
.cb-crt .qz-crt__list { gap: var(--space-3); }
.cb-crt .qz-crt__foot { margin-block-start: var(--space-2); padding-block-start: var(--space-3); }
@media (min-width: 48rem) {
  .cb-hero { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--space-12); }
}

/* The band that holds a state that arrives from the network (form or closed, loading or ready, login or desk) is at least a screen tall,
   so the footer stays below the fold while the state swaps and nothing visible moves. */
.cb-gate { min-height: calc(100svh - var(--space-24) * 2); }

/* Plain page head on the status page and the desk. */
.cb-head { display: grid; gap: var(--space-3); justify-items: start; }

/* The form band: a short aside, then the form in a card. */
.cb-apply { display: grid; gap: var(--space-8); align-items: start; }
.cb-aside { display: grid; gap: var(--space-4); justify-items: start; }
.cb-main { display: grid; gap: var(--space-6); min-width: 0; }
@media (min-width: 64rem) {
  .cb-apply { grid-template-columns: minmax(0, var(--size-aside)) minmax(0, var(--size-prose)); justify-content: space-between; gap: var(--space-16); }
  .cb-aside { position: sticky; inset-block-start: var(--space-8); }
}
.cb-panel { display: grid; gap: var(--space-6); max-width: calc(var(--size-prose) * 1.2); margin-inline: auto; }
.cb-panel--wide { max-width: var(--page-max); }

/* Card: the one surface the forms and states sit on. A sheet with a hairline edge, no shadow. */
.cb-card { display: grid; gap: var(--space-8); min-width: 0; padding: var(--space-6); border: var(--border-hair) solid var(--color-hairline); border-radius: var(--radius-md); background: var(--color-sheet); }
.cb-card--narrow { width: 100%; max-width: var(--size-form-max); margin-inline: auto; }
@media (min-width: 48rem) { .cb-card { padding: var(--space-8); } }
/* The human check is a fixed 300px widget: at 320px the card gives it the room by trimming its side padding, and the row scrolls rather than clips if the screen is still narrower. */
@media (max-width: 24rem) { .cb-card { padding-inline: var(--space-3); } .cb-card .captcha { max-width: 100%; overflow-x: auto; } }

/* A card that is shown by a state change arrives with a short rise. Opacity and transform only, nothing moves the layout. */
@keyframes cb-in { from { opacity: 0; transform: translateY(var(--space-2)); } }
@keyframes cb-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: no-preference) {
  .cb-card:not([hidden]) { animation: cb-in var(--duration-base) var(--ease-out) both; }
}
@media (prefers-reduced-motion: reduce) {
  .cb-card:not([hidden]) { animation: cb-fade var(--duration-base) var(--ease-out) both; }
}

/* Form: groups are separated by space (twice the gap inside a group), not by rules. */
.cb-form { display: grid; gap: var(--space-12); }
.cb-group { display: grid; gap: var(--space-4); min-width: 0; }
.cb-group > .qz-h3 { margin-block-end: var(--space-1); }
.cb-field { display: grid; gap: var(--space-2); align-content: start; min-width: 0; }
.cb-pair { display: grid; gap: var(--space-4); }
@media (min-width: 48rem) { .cb-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cb-label { padding: 0; color: var(--color-ink); font-size: var(--text-caption-size); line-height: var(--text-caption-line); font-weight: 600; letter-spacing: var(--text-caption-tracking); text-transform: uppercase; text-wrap: balance; }
.cb-field .help { text-wrap: pretty; }
.cb-send { display: grid; gap: var(--space-3); }
.cb-wide { inline-size: 100%; }

/* Inputs: a visible ink-muted edge (3:1 on the sheet), body size so a phone does not zoom, 44px tall. */
.cb-input { inline-size: 100%; min-width: 0; min-height: var(--hit); padding: var(--space-2) var(--space-3); border: var(--border-rule) solid var(--color-ink-muted); border-radius: var(--radius-sm); background: var(--color-page); color: var(--color-ink); font: inherit; line-height: 1.3; text-align: start; overflow-wrap: anywhere; transition: border-color var(--duration-fast) var(--ease-out); }
.cb-input::placeholder { color: var(--color-ink-muted); opacity: 1; }
.cb-input:focus-visible { outline-offset: 0; border-color: var(--color-accent); }
.cb-input[aria-invalid='true'] { border-color: var(--color-risk); }
.cb-input[readonly] { background: var(--color-sunk); }
.cb-area { min-height: calc(var(--hit) * 2.5); resize: vertical; }
select.cb-input { cursor: pointer; }
.cb-input:disabled { cursor: not-allowed; color: var(--color-ink-muted); }

/* Kind of collab: each choice is a full-width 44px tile; the real checkbox covers it, invisible, so a tap anywhere toggles it. */
.cb-checks { display: grid; gap: var(--space-3); min-width: 0; margin: 0; padding: 0; border: 0; }
.cb-checks > legend { margin-block-end: var(--space-2); }
.cb-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--size-grid-min)), 1fr)); gap: var(--space-3); }
.cb-choice { position: relative; display: flex; align-items: center; min-height: var(--hit); padding: var(--space-2) var(--space-3); border: var(--border-hair) solid var(--color-hairline); border-radius: var(--radius-sm); background: var(--color-page); cursor: pointer; touch-action: manipulation; transition: border-color var(--duration-fast) var(--ease-out), background-color var(--duration-fast) var(--ease-out); }
.cb-choice input { position: absolute; inset: calc(var(--border-hair) * -1); inline-size: calc(100% + var(--border-hair) * 2); block-size: calc(100% + var(--border-hair) * 2); margin: 0; opacity: 0; cursor: pointer; }
.cb-choice span { position: relative; display: flex; align-items: center; gap: var(--space-3); min-width: 0; line-height: 1.3; overflow-wrap: anywhere; }
.cb-choice span::before { content: ''; flex: none; inline-size: var(--size-icon); block-size: var(--size-icon); border: var(--border-rule) solid var(--color-ink-muted); border-radius: var(--radius-sm); background: var(--color-sheet); transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out); }
.cb-choice span::after { content: ''; position: absolute; inset-inline-start: calc(var(--size-icon) * 0.36); inset-block-start: 50%; inline-size: calc(var(--size-icon) * 0.28); block-size: calc(var(--size-icon) * 0.52); border: solid var(--color-accent-ink); border-width: 0 var(--border-heavy) var(--border-heavy) 0; opacity: 0; transform: translateY(-62%) rotate(45deg); transition: opacity var(--duration-fast) var(--ease-out); }
.cb-choice:has(input:checked) { border-color: var(--color-accent); background: var(--color-sheet); }
.cb-choice input:checked + span::before { border-color: var(--color-accent); background: var(--color-accent); }
.cb-choice input:checked + span::after { opacity: 1; }
.cb-choice input:focus-visible + span::before { outline: var(--border-focus) solid var(--color-accent); outline-offset: var(--border-heavy); }

/* Press feedback: a short scale on the real controls. Hover only where a pointer can hover. */
:is(.cb-card, .cb-copy) :is(.qz-btn, button) { touch-action: manipulation; user-select: none; -webkit-tap-highlight-color: transparent; transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out); }
:is(.cb-card, .cb-copy) .qz-btn:active:not(:disabled) { transform: scale(0.97); }
.cb-choice:active { background: var(--color-sunk); }
@media (hover: hover) and (pointer: fine) {
  .cb-input:hover:not(:disabled, [readonly]) { border-color: var(--color-ink); }
  .cb-choice:hover { border-color: var(--color-ink-muted); }
  .cb-choice:has(input:checked):hover { border-color: var(--color-accent-hover); }
}

/* Sent card: the status link and its copy button sit on one row from 48rem. */
.cb-copy-row { display: grid; gap: var(--space-3); }
@media (min-width: 48rem) { .cb-copy-row { grid-template-columns: minmax(0, 1fr) auto; } }
.cb-copied { min-height: var(--text-caption-line); color: var(--color-ink-muted); font-size: var(--text-caption-size); font-weight: 600; }
.cb-copied:empty { display: none; }

/* Notice: one plain line in a bordered box. The colour is never the only signal; the text says it. */
.cb-notice { padding: var(--space-3) var(--space-4); border: var(--border-hair) solid var(--color-pending); border-radius: var(--radius-sm); background: var(--color-pending-wash); color: var(--color-ink); font-size: var(--text-caption-size); line-height: var(--text-caption-line); font-weight: 600; text-wrap: pretty; overflow-wrap: anywhere; }
.cb-notice--risk { border-color: var(--color-risk); background: var(--color-risk-wash); }

/* Status page: the readout is a small CRT with the state lit, then the plain sentence and the facts. */
.cb-readout { --size-crt-amount: var(--text-h1-size); --crt-size: var(--text-lead-size); justify-items: start; gap: var(--space-3); padding: var(--space-6); }
.cb-readout .qz-crt__amount { margin: 0; }
.cb-readout .qz-crt__label { margin: 0; }
#state[data-status='declined'] { color: var(--color-screen-dim); }
.cb-facts { display: grid; gap: var(--space-4); margin: 0; }
.cb-facts > div { display: grid; gap: var(--space-1); min-width: 0; }
.cb-facts dt { color: var(--color-ink-muted); font-size: var(--text-caption-size); line-height: var(--text-caption-line); font-weight: 600; letter-spacing: var(--text-caption-tracking); text-transform: uppercase; }
.cb-facts dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (min-width: 48rem) { .cb-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6); } }

/* Desk: dense, on tokens. A toolbar, a count, then the table. */
.cb-desk { display: grid; gap: var(--space-4); min-width: 0; }
.cb-bar { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: end; }
.cb-filter { min-inline-size: calc(var(--size-grid-min) * 0.7); }
@media (min-width: 48rem) { .cb-out { margin-inline-start: auto; } }
.cb-count { color: var(--color-ink-muted); font-size: var(--text-caption-size); line-height: var(--text-caption-line); font-variant-numeric: tabular-nums; }
.cb-btn-sm { padding-inline: var(--space-4); }

/* Table. Under 80rem each application is a card of label and value pairs; from 80rem it is a real table with fixed column widths, so a long
   name or link wraps inside its own column. The header row is visually hidden below that, and each cell carries its own label
   (data-label, set by collab-admin.js). */
.cb-table { min-width: 0; }
.cb-table table, .cb-table tbody, .cb-table tr, .cb-table td { display: block; }
.cb-thead { position: absolute; inline-size: var(--border-hair); block-size: var(--border-hair); overflow: hidden; clip-path: inset(100%); white-space: nowrap; }
.cb-table tr { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--size-grid-min)), 1fr)); gap: var(--space-4); margin-block-end: var(--space-3); padding: var(--space-4); border: var(--border-hair) solid var(--color-hairline); border-radius: var(--radius-md); background: var(--color-sheet); }
.cb-table td { display: grid; gap: var(--space-1); align-content: start; min-width: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.cb-table td:nth-child(2), .cb-table td:last-child { grid-column: 1 / -1; }
.cb-table td::before { content: attr(data-label); color: var(--color-ink-muted); font-size: var(--text-caption-size); line-height: var(--text-caption-line); font-weight: 600; letter-spacing: var(--text-caption-tracking); text-transform: uppercase; }
.cb-table td a { display: inline-flex; align-items: center; min-width: var(--hit); min-height: var(--hit); font-weight: 600; }
.cb-note { display: grid; gap: var(--space-1); margin-block-start: var(--space-2); color: var(--color-ink-muted); font-size: var(--text-caption-size); line-height: var(--text-caption-line); }
.cb-note p { overflow-wrap: anywhere; }
.cb-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.cb-chip { display: inline-block; justify-self: start; padding: var(--space-1) var(--space-3); border: var(--border-hair) solid var(--color-ink-muted); border-radius: var(--radius-sm); color: var(--color-ink); font-size: var(--text-caption-size); line-height: var(--text-caption-line); font-weight: 600; white-space: nowrap; }
.cb-chip--new { border-color: var(--color-pending); background: var(--color-pending-wash); }
@media (min-width: 80rem) {
  .cb-table table { display: table; inline-size: 100%; table-layout: fixed; border-collapse: collapse; }
  .cb-table tbody { display: table-row-group; }
  .cb-thead { position: static; inline-size: auto; block-size: auto; overflow: visible; clip-path: none; display: table-header-group; white-space: normal; }
  .cb-thead th { padding: var(--space-3) var(--space-4); border-block-end: var(--border-rule) solid var(--color-ink); color: var(--color-ink-muted); font-size: var(--text-caption-size); line-height: var(--text-caption-line); font-weight: 600; letter-spacing: var(--text-caption-tracking); text-align: start; text-transform: uppercase; white-space: nowrap; }
  .cb-thead th:nth-child(1) { inline-size: calc(var(--size-grid-min) * 0.75); }
  .cb-thead th:nth-child(3) { inline-size: calc(var(--size-grid-min) * 0.6); }
  .cb-thead th:nth-child(4), .cb-thead th:nth-child(5) { inline-size: calc(var(--size-grid-min) * 0.7); }
  .cb-thead th:nth-child(6) { inline-size: calc(var(--size-grid-min) * 0.5); }
  .cb-thead th:nth-child(7) { inline-size: calc(var(--size-grid-min) * 0.95); }
  .cb-table tr { display: table-row; margin: 0; padding: 0; border: 0; border-radius: 0; background: none; }
  .cb-table td { display: table-cell; padding: var(--space-4); border-block-end: var(--border-hair) solid var(--color-hairline); vertical-align: top; }
  .cb-table td::before { display: none; }
  .cb-actions { flex-wrap: wrap; }
}
@media (min-width: 80rem) and (hover: hover) and (pointer: fine) {
  .cb-table tbody tr:hover { background: var(--color-sheet); }
}

/* Winners' wallets: the list form on the status page and the import panel on the desk. Addresses are set in a monospace face at body size. */
.cb-wallets { display: grid; gap: var(--space-6); padding-block-start: var(--space-8); border-block-start: var(--border-hair) solid var(--color-hairline); }
:root { --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; }
.cb-mono, .cb-addrs { font-family: var(--font-mono); }
.cb-lines { white-space: pre-line; overflow-wrap: anywhere; }
.cb-ok { color: var(--color-ink); font-size: var(--text-caption-size); line-height: var(--text-caption-line); font-weight: 600; }
.cb-ok:empty { display: none; }
.cb-saved { display: grid; gap: var(--space-3); min-width: 0; }
.cb-saved summary, .cb-import summary { display: flex; align-items: center; min-height: var(--hit); font-weight: 600; cursor: pointer; }
.cb-addrs { display: grid; gap: var(--space-2); margin: 0; padding: var(--space-3) var(--space-4); list-style: none; border: var(--border-hair) solid var(--color-hairline); border-radius: var(--radius-sm); background: var(--color-page); max-block-size: calc(var(--hit) * 8); overflow-y: auto; font-variant-numeric: tabular-nums; }
.cb-addrs li { overflow-wrap: anywhere; }
.cb-import { min-width: 0; }
.cb-import > .cb-form { margin-block-start: var(--space-2); max-inline-size: 40rem; }
.cb-import .cb-form { gap: var(--space-4); }
.cb-table tr.cb-panel-row { margin-block-start: calc(var(--space-3) * -1); }
.cb-table tr.cb-panel-row td::before { display: none; }
.cb-spots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
