/* Qmanja Key Issuer: the key-cutting bench (see DESIGN.md).
   Order: tokens, base, layout, controls, components, pages, utilities, reduced motion, print.
   CSP: style-src 'self', so every style lives here; the only images are data: SVGs (img-src allows data:). */

/* ---------- Tokens ---------- */
:root {
    --ground: #F2F3F1;
    --surface: #FFFFFF;
    --ink: #15181C;
    --ink-2: #1E2227;        /* fields on the ink card */
    --ink-3: #6B727A;        /* field edge on the ink card: 3.66:1 on ink */
    --muted: #5A616A;        /* 5.63:1 on ground, 6.26:1 on surface */
    --steel: #A9B0B8;        /* meta text on ink, 8.13:1 */
    --line: #D5D9DD;
    --line-field: #838A92;   /* field edges: 3.49:1 on surface, 3.14:1 on ground (WCAG 1.4.11) */
    --brass: #9A6A12;        /* focus ring, markers, the bitting strip */
    --brass-tint: #F6EBD3;
    --brass-deep: #6E4C0D;   /* text on brass-tint, 6.57:1 */
    --danger: #A8261B;
    --danger-tint: #FBEDEB;
    --ok: #1D6A3A;
    --ok-tint: #E6F1EA;
    --quiet-tint: #ECEEEF;
    --row-hover: #F7F8F6;
    --on-ink-soft: rgb(255 255 255 / 0.78);

    --font-sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "Cascadia Mono", "Cascadia Code", ui-monospace, "SFMono-Regular", Consolas, monospace;

    --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
    --radius: 6px;
    --ease: cubic-bezier(.2, .7, .2, 1);
    --t-control: 140ms;
    --t-card: 320ms;

    --w-form: 44rem;
    --w-wide: 76rem;
    --w-auth: 26rem;
    --gutter: clamp(16px, 4vw, 32px);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--ground);
    color: var(--ink);
    font: 400 16px/1.5 var(--font-sans);
    font-kerning: normal;
    -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; font-family: var(--font-display); color: inherit; text-wrap: balance; }
h1 { font-size: clamp(1.75rem, 1.4rem + 1.2vw, 2.4rem); font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }
h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
p { margin: 0 0 var(--s-4); }
strong { font-weight: 600; }
a { color: inherit; text-decoration-color: var(--brass); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
code, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
code { font-size: 0.92em; }
.mono { overflow-wrap: anywhere; }
::selection { background: var(--brass-tint); color: var(--ink); }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
#main:focus { outline: none; }

.skip-link {
    position: absolute; left: var(--s-4); top: var(--s-3); z-index: 20;
    padding: 10px 16px; border-radius: var(--radius);
    background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none;
    transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* ---------- Layout ---------- */
.site-header { background: var(--ink); color: #fff; }
.site-header__inner {
    display: flex; align-items: center; flex-wrap: wrap; gap: 0 var(--s-6);
    max-width: calc(var(--w-wide) + 2 * var(--gutter)); min-height: 56px;
    margin: 0 auto; padding: 0 var(--gutter);
}
.brand {
    display: inline-flex; align-items: center; gap: 10px; min-height: 44px;
    color: #fff; font-size: 15px; font-weight: 600; letter-spacing: -0.005em; text-decoration: none;
}
.brand__mark {
    width: 30px; height: 16px; flex: none;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 16'%3E%3Cg fill='none' stroke='%23fff' stroke-width='2'%3E%3Ccircle cx='6' cy='8' r='4.5'/%3E%3Cpath d='M10.5 8H29M16 8v4M20 8v2.5M24 8v5'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}
.site-nav { display: flex; flex: 1; flex-wrap: wrap; align-self: stretch; }
.site-nav a {
    position: relative; display: inline-flex; align-items: center; min-height: 56px; padding: 0 12px;
    color: var(--on-ink-soft); font-size: 14.5px; font-weight: 500; text-decoration: none;
    transition: color var(--t-control) var(--ease);
}
.site-nav a::after {
    content: ""; position: absolute; left: 12px; right: 12px; bottom: 12px; height: 2px;
    background: var(--brass); transform: scaleX(0); transform-origin: left;
    transition: transform var(--t-control) var(--ease);
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: #fff; }
.site-nav a:hover::after, .site-nav a[aria-current="page"]::after { transform: scaleX(1); }
.site-nav a:focus-visible, .brand:focus-visible { outline-offset: -4px; }
.site-nav__out { margin-left: auto; }

.page {
    width: 100%; max-width: calc(var(--w-wide) + 2 * var(--gutter));
    margin: 0 auto; padding: var(--s-7) var(--gutter) var(--s-8);
}
.page:not([class*="page--"]) > * { max-width: var(--w-form); }
/* Auth shell: the one card sits in the middle of the screen, a little above true centre. */
.page--auth {
    display: flex; flex-direction: column; justify-content: center;
    min-height: calc(100vh - 56px); min-height: calc(100dvh - 56px);
    padding-top: var(--s-7); padding-bottom: calc(var(--s-8) * 2);
}
.page--auth > .auth { width: 100%; margin-inline: auto; }

.title-row {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-2) var(--s-4);
    margin-bottom: var(--s-6); padding-bottom: var(--s-4); border-bottom: 1px solid var(--line);
}
.title-row h1::before { content: ""; display: block; width: 24px; height: 3px; margin-bottom: 14px; background: var(--brass); }
.title-row__meta { margin: 0; color: var(--muted); font-size: 14px; font-weight: 500; letter-spacing: 0.01em; }

/* ---------- Controls ---------- */
.form { display: grid; gap: 20px; }
.field { display: grid; gap: 6px; min-width: 0; margin: 0; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset.field > legend { margin-bottom: 6px; }
label, legend { display: block; padding: 0; color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.35; }
.hint { display: block; color: var(--muted); font-size: 13.5px; line-height: 1.45; }

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea {
    width: 100%; min-height: 44px; margin: 0; padding: 0 12px;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--line-field); border-radius: var(--radius);
    font: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */
    transition: border-color var(--t-control) var(--ease), box-shadow var(--t-control) var(--ease);
}
textarea { padding: 10px 12px; line-height: 1.5; resize: vertical; }
select {
    appearance: none; padding-right: 36px; cursor: pointer;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2315181C' stroke-width='1.5'/%3E%3C/svg%3E") right 12px center / 10px 6px no-repeat;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid transparent; /* kept for forced-colors mode */
    border-color: var(--ink); box-shadow: 0 0 0 2px var(--brass);
}
[aria-invalid="true"], [aria-invalid="true"]:hover { border-color: var(--danger); }
input.mono { font-family: var(--font-mono); font-size: 15px; letter-spacing: 0.02em; }
input.date, input[type="date"] { max-width: 12rem; font-variant-numeric: tabular-nums; }
input.code { font-family: var(--font-mono); font-size: 20px; letter-spacing: 0.3em; }

.field-error:empty { display: none; }
.field-error { display: flex; gap: 8px; align-items: flex-start; color: var(--danger); font-size: 13.5px; font-weight: 600; line-height: 1.45; }
.field-error::before {
    content: "!"; content: "!" / "";
    flex: none; display: inline-grid; place-items: center; width: 16px; height: 16px; margin-top: 2px;
    border-radius: 50%; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 1;
}

.check {
    display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; cursor: pointer;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    font-size: 15px; font-weight: 500; transition: border-color var(--t-control) var(--ease);
}
.check:hover { border-color: var(--muted); }
.check input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--ink); }
.check:has(input:checked) { border-color: var(--ink); }

/* Segmented radio group: one bordered strip, 1px dividers from the grid gap. */
.segmented {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px;
    background: var(--line); border: 1px solid var(--line-field); border-radius: var(--radius); overflow: hidden;
}
.segment { position: relative; display: block; margin: 0; cursor: pointer; }
.segment:last-child { grid-column: 1 / -1; }
.segment__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.segment__body {
    display: flex; flex-direction: column; justify-content: center; gap: 2px; height: 100%; min-height: 56px; padding: 8px 12px;
    background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600;
    transition: background-color var(--t-control) var(--ease), color var(--t-control) var(--ease), box-shadow var(--t-control) var(--ease);
}
.segment__meta { color: var(--muted); font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.segment:hover .segment__body { background: var(--row-hover); }
.segment__input:checked + .segment__body { background: var(--ink); color: #fff; box-shadow: inset 0 -3px 0 var(--brass); }
.segment__input:checked + .segment__body .segment__meta { color: var(--steel); }
.segment__input:focus-visible + .segment__body { outline: 2px solid var(--brass); outline-offset: -4px; }
/* The custom date. Without :has() it always shows; with it, it shows only for "On date", seated under the strip. */
.segmented-date { display: grid; gap: 6px; margin-top: 8px; }
.segmented-date label { color: var(--muted); font-size: 13px; }
@supports selector(:has(*)) {
    .issue-form:not(:has(#expiry-custom:checked)) .segmented-date { display: none; }
    .issue-form:has(#expiry-custom:checked) .segmented { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
    .issue-form:has(#expiry-custom:checked) .segmented-date {
        margin-top: 0; padding: 12px; background: var(--surface);
        border: 1px solid var(--line-field); border-top: 0; border-radius: 0 0 var(--radius) var(--radius);
        animation: seat-down var(--t-control) var(--ease) both;
    }
}

/* Buttons: one treatment per role. */
.btn {
    position: relative; isolation: isolate; overflow: hidden;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; margin: 0; padding: 0 20px;
    border: 1px solid transparent; border-radius: var(--radius);
    font: inherit; font-size: 15px; font-weight: 600; line-height: 1.2; letter-spacing: 0.005em;
    text-decoration: none; white-space: nowrap; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
    transition: transform var(--t-control) var(--ease), color var(--t-control) var(--ease),
                border-color var(--t-control) var(--ease), box-shadow var(--t-control) var(--ease);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--block { width: 100%; }

.btn--primary { background: var(--ink); color: #fff; }
.btn__label { position: relative; }
.btn__label::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -5px; height: 3px;
    background: var(--brass); transform: scaleX(0); transform-origin: left;
    transition: transform var(--t-control) var(--ease);
}
.btn--primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 16px -10px rgb(21 24 28 / 0.7); }
.btn--primary:hover:not(:disabled) .btn__label::after { transform: scaleX(1); }
.btn--primary:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }

/* Secondary and danger: the fill seats in from the left. */
.btn--secondary, .btn--danger { background: var(--surface); }
.btn--secondary { color: var(--ink); border-color: var(--ink); }
.btn--danger { color: var(--danger); border-color: var(--danger); }
.btn--secondary::before, .btn--danger::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    transform: scaleX(0); transform-origin: left; transition: transform var(--t-control) var(--ease);
}
.btn--secondary::before { background: var(--ink); }
.btn--danger::before { background: var(--danger); }
.btn--secondary:hover:not(:disabled), .btn--danger:hover:not(:disabled) { color: #fff; }
.btn--secondary:hover:not(:disabled)::before, .btn--danger:hover:not(:disabled)::before { transform: scaleX(1); }
.btn--secondary:active:not(:disabled), .btn--danger:active:not(:disabled) { transform: translateY(1px); }

.btn--on-ink { background: transparent; color: #fff; border-color: rgb(255 255 255 / 0.55); }
.btn--on-ink::before { background: #fff; }
.btn--on-ink:hover:not(:disabled) { color: var(--ink); border-color: #fff; }

.btn--small { min-height: 32px; padding: 0 12px; font-size: 13.5px; }

/* ---------- Components ---------- */
.error, .ok, .notice {
    margin: 0 0 var(--s-5); padding: 12px 16px; border-left: 3px solid; border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 15px; font-weight: 500;
}
.error { border-color: var(--danger); background: var(--danger-tint); color: var(--danger); }
.ok { border-color: var(--ok); background: var(--ok-tint); color: var(--ok); }
.notice { border-color: var(--brass); background: var(--brass-tint); color: var(--ink); }
.notice a { font-weight: 600; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-6) 28px; }
.card__foot { margin: 20px 0 0; font-size: 14px; }
.card__actions { margin: var(--s-5) 0 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-5); }
.eyebrow {
    display: flex; align-items: center; gap: 10px; margin: 0 0 var(--s-4);
    color: var(--muted); font-size: 12.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
}
.eyebrow::before { content: ""; width: 16px; height: 3px; background: var(--brass); }
.lede { color: var(--muted); }
.meta { color: var(--muted); font-size: 14px; }
.meta code { color: var(--ink); }

.pill {
    display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
    font-size: 12.5px; font-weight: 600; letter-spacing: 0.01em; line-height: 1.5; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--active { background: var(--ok-tint); color: var(--ok); }
.pill--expired { background: var(--quiet-tint); color: var(--muted); }
.pill--invited { background: var(--brass-tint); color: var(--brass-deep); }
.pill--disabled { background: var(--danger-tint); color: var(--danger); }

/* Toolbars and the History view switcher. */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-4) var(--s-5); margin-bottom: var(--s-5); }
.toolbar__search { display: grid; gap: 6px; flex: 1 1 20rem; max-width: 28rem; }
.inline-field { display: flex; gap: var(--s-2); }
.inline-field input { flex: 1; min-width: 0; }
.toolbar--filters { justify-content: flex-start; padding: var(--s-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.toolbar--filters .field { flex: 0 1 12rem; }

.views { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.views a {
    display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border-radius: 4px;
    color: var(--ink); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; text-decoration: none; white-space: nowrap;
    transition: background-color var(--t-control) var(--ease), color var(--t-control) var(--ease);
}
.views a:hover { background: var(--row-hover); }
.views a.current { background: var(--ink); color: #fff; }

/* Tables */
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.empty { padding: var(--s-6) var(--s-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.empty__text { margin: 0; color: var(--muted); font-size: 15px; }
.empty__actions { margin: var(--s-4) 0 0; }
.table-wrap { overflow-x: auto; overscroll-behavior-x: contain; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14.5px; }
th {
    padding: 12px 16px; text-align: left; white-space: nowrap; background: var(--surface);
    color: var(--muted); font-size: 12.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
    border-bottom: 1px solid var(--line);
}
td { height: 48px; padding: 10px 16px; vertical-align: middle; background: var(--surface); border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--row-hover); }
th:first-child, td:first-child { position: sticky; left: 0; z-index: 1; }
td.mono { font-size: 13.5px; }
td.num { white-space: nowrap; }
td.truncate { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.details { min-width: 18rem; overflow-wrap: anywhere; }
th.actions, td.actions { text-align: right; }
/* One line of controls per row; a narrow screen scrolls the table instead of wrapping them. */
.actions__row { display: flex; flex-wrap: nowrap; justify-content: flex-end; align-items: center; gap: var(--s-2); white-space: nowrap; }
.actions__row form, .role-form { display: flex; margin: 0; }
.role-form { flex-wrap: nowrap; align-items: center; gap: 6px; white-space: nowrap; }
/* Users: dense so a full row of controls fits one line from 1100px. */
.table--dense th, .table--dense td { padding-left: 10px; padding-right: 10px; }
.table--dense td.num { font-size: 13.5px; }
.table--dense th { white-space: normal; vertical-align: bottom; }
.table--dense th.nowrap { white-space: nowrap; }
td.email { min-width: 7rem; overflow-wrap: anywhere; }
td.role-cell { padding-top: 8px; padding-bottom: 8px; white-space: nowrap; }
select.select--small { width: auto; min-height: 32px; height: 32px; padding: 0 30px 0 10px; font-size: 13.5px; background-position: right 10px center; }

/* ---------- Pages ---------- */
/* Issue: the bench. Form beside the key card from 1100px. */
.bench { display: grid; gap: var(--s-7); }
.bench__form .form { max-width: var(--w-form); }
.form__actions { padding-top: var(--s-1); }
.jump-to-key a { font-weight: 600; }

.note { padding: var(--s-5); border: 1px solid var(--line); border-radius: var(--radius); }
.note h2 { margin-bottom: var(--s-4); font-size: 1rem; }
.note__list { display: grid; gap: var(--s-4); margin: 0; padding: 0; list-style: none; counter-reset: fact; }
.note__list li { display: grid; grid-template-columns: 2.25rem 1fr; gap: var(--s-2); counter-increment: fact; font-size: 14.5px; }
.note__list li::before {
    content: counter(fact, decimal-leading-zero); content: counter(fact, decimal-leading-zero) / "";
    align-self: start; padding-top: 4px; border-top: 2px solid var(--brass);
    color: var(--muted); font-family: var(--font-mono); font-size: 12.5px; line-height: 1.4;
}

.keycard {
    display: grid; gap: 20px; padding: var(--s-5); border-radius: var(--radius);
    background: var(--ink); color: #fff;
    box-shadow: 0 24px 48px -28px rgb(21 24 28 / 0.6);
    animation: seat-card var(--t-card) var(--ease) both;
}
.keycard__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
.keycard__tag { color: var(--steel); font-size: 12.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.bitting { display: block; width: 100%; height: auto; max-height: 72px; animation: seat 180ms var(--ease) 200ms both; }
.bitting__blade { fill: var(--brass); }
.bitting__bow { fill: none; stroke: var(--brass); stroke-width: 17; }
.bitting__groove { fill: none; stroke: var(--ink); stroke-width: 2; opacity: 0.55; }
.bitting__ticks { fill: none; stroke: rgb(255 255 255 / 0.4); stroke-width: 1; }
.keycard__meta { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3) 20px; margin: 0; }
.keycard__meta > div { min-width: 0; }
.keycard__meta > div:nth-child(n+3) { grid-column: 1 / -1; }
.keycard dt { margin-bottom: 2px; color: var(--steel); font-size: 12.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.keycard dd { margin: 0; overflow-wrap: anywhere; font-size: 14.5px; }
.keycard dd.mono { font-size: 13.5px; }
.keycard label { margin-bottom: -14px; color: #fff; }
textarea.keycard__key {
    background: var(--ink-2); color: #fff; border-color: var(--ink-3);
    font-family: var(--font-mono); font-size: 13.5px; letter-spacing: 0.02em; line-height: 1.55; word-break: break-all;
    field-sizing: content; min-height: 8lh; max-height: 22lh;
}
textarea.keycard__key:hover { border-color: var(--steel); }
textarea.keycard__key:focus-visible { border-color: var(--steel); }
.keycard__warn { margin: 0; font-size: 14px; font-weight: 600; }
.keycard__actions { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.keycard__actions form { display: flex; margin: 0; }

/* Users */
.new-link { margin: 0 0 var(--s-6); padding: var(--s-5); border-radius: var(--radius); background: var(--ink); color: #fff; max-width: 52rem; }
.new-link h2 { margin-bottom: var(--s-3); }
.new-link p { color: var(--steel); }
.new-link__url code {
    display: block; padding: 12px; border: 1px solid var(--ink-3); border-radius: var(--radius);
    background: var(--ink-2); color: #fff; font-size: 14px; overflow-wrap: anywhere;
}
.invite { max-width: var(--w-form); margin-top: var(--s-7); }
.invite h2 { margin-bottom: var(--s-4); }
.invite__form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-4); }
.invite__form .field { flex: 0 1 10rem; }
.toolbar--filters .field--grow, .invite__form .field--grow { flex: 1 1 14rem; }

/* Auth, Error, AccessDenied: one card. Enrol: two numbered step cards. */
.auth { max-width: var(--w-auth); }
.auth__card h1 { margin-bottom: var(--s-5); }
.auth__card .form { gap: 20px; }
.auth__card .form .btn { margin-top: var(--s-1); }
.enrol { max-width: 60rem; margin-inline: auto; } /* centred column, like the auth card */
.enrol h1 { margin-bottom: var(--s-4); }
.enrol .lede { max-width: var(--w-form); margin-bottom: var(--s-6); }
.steps { display: grid; gap: var(--s-5); align-items: start; }
.step h2 { margin-bottom: var(--s-4); }
.step__num { color: var(--muted); font-family: var(--font-mono); font-weight: 500; }
.qr { display: inline-block; margin: 0 0 var(--s-4); padding: var(--s-4); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.qr svg { display: block; width: 200px; height: 200px; }
.secret { margin: 0; }
#secret {
    display: inline-block; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--ground); font-size: 17px; letter-spacing: 0.12em; word-spacing: 0.25em; overflow-wrap: anywhere;
}

.page-note { margin-bottom: var(--s-3); }
.page-foot { margin-top: var(--s-3); }

/* ---------- Breakpoints ---------- */
@media (min-width: 560px) {
    .segmented { grid-template-columns: repeat(5, 1fr); }
    .segment:last-child { grid-column: auto; }
}
@media (min-width: 900px) {
    .steps { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1100px) {
    .bench { grid-template-columns: 7fr 5fr; gap: var(--s-7); }
    .keycard { position: sticky; top: var(--s-5); }
    .jump-to-key { display: none; }
}
@media (max-width: 640px) {
    .site-header__inner { padding-top: 4px; padding-bottom: 4px; }
    .brand { flex-basis: 100%; }
    .site-nav { margin-left: -10px; }
    .site-nav a { min-height: 44px; padding: 0 10px; }
    .site-nav a::after { left: 10px; right: 10px; bottom: 8px; }
    .page { padding-top: var(--s-5); }
    .page--auth { padding-top: var(--s-6); padding-bottom: var(--s-8); justify-content: flex-start; }
    .card { padding: var(--s-5) 20px; }
    .form .btn, .invite__form .btn, .toolbar .btn, .card__actions .btn, .keycard__actions .btn, .keycard__actions form { width: 100%; }
    .inline-field { flex-direction: column; }
    .toolbar__search, .toolbar--filters .field, .toolbar__submit, .invite__form .field, .invite__submit { flex: 1 1 100%; max-width: none; }
    .views { display: flex; }
    .views a { flex: 1 1 auto; justify-content: center; }
    th:first-child, td:first-child { box-shadow: 1px 0 0 var(--line); }
}

/* ---------- Utilities ---------- */
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---------- Motion ---------- */
@keyframes seat { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }
@keyframes seat-down { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes seat-card { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Print: the key, nothing else to press ---------- */
@media print {
    body { background: #fff; }
    .site-header, .skip-link, .btn, .toolbar, .views, .jump-to-key, .note, .keycard__actions, .invite { display: none !important; }
    .page { padding: 0; max-width: none; }
    .bench { display: block; }
    .keycard { position: static; box-shadow: none; border: 1px solid #000; background: #fff; color: #000; animation: none; }
    .keycard dt, .keycard__tag { color: #444; }
    .bitting { animation: none; }
    .bitting__blade { fill: #000; }
    .bitting__bow { stroke: #000; }
    textarea.keycard__key { height: auto; max-height: none; background: #fff; color: #000; border-color: #000; font-family: var(--font-mono); }
    .table-card { border-color: #999; }
    .table-wrap { overflow: visible; }
    th:first-child, td:first-child { position: static; }
}
