/*
 * deadkey.net — Design System
 * Version: 0.1
 *
 * Architecture:
 *   1. Custom properties (tokens)
 *   2. CSS reset (self-contained, no external dependency)
 *   3. Base / typography
 *   4. Layout primitives
 *   5. Components
 *      5a. Buttons
 *      5b. Form fields
 *      5c. Cards
 *      5d. Callouts / alerts
 *      5e. Step progress indicator
 *      5f. Argon2 wait state
 *      5g. Navigation
 *      5h. Footer
 *      5i. Attrition gate (trigger confirmation)
 *      5j. Data tables (long-form documentation pages)
 *      5k. Status pill (status.html)
 *   6. Page-level patterns
 *      6a. Landing page hero
 *      6b. Wizard layout
 *      6c. Print sheet components
 *   7. Utility classes
 *   8. @media print (paper artifacts)
 *   9. @media (prefers-reduced-motion)
 *  10. Responsive overrides
 */

/* ============================================================
   1. CUSTOM PROPERTIES
   ============================================================ */

:root {
  /* --- Color: Backgrounds & Surfaces --- */
  --color-bg:             #f5f4f2;
  --color-surface:        #ffffff;
  --color-surface-raised: #f0eeeb;

  /* --- Color: Borders --- */
  --color-border:         #d4d0cb;
  --color-border-strong:  #a09a91;

  /* --- Color: Text --- */
  --color-text-primary:   #1a1917;
  --color-text-secondary: #5c564e;
  --color-text-muted:     #8c857c;
  --color-text-inverted:  #f5f4f2;

  /* --- Color: Brand (dark slate-blue) --- */
  --color-brand:          #2c4a6e;
  --color-brand-hover:    #1e3550;
  --color-brand-light:    #dde6f0;

  /* --- Color: Accent (muted sage green — "Create" CTA) --- */
  --color-accent:         #3d6b5a;
  --color-accent-hover:   #2c5042;
  --color-accent-light:   #ddf0e8;

  /* --- Color: Semantic --- */
  --color-warning-bg:     #fdf3dd;
  --color-warning-border: #c8932a;
  --color-warning-text:   #7a5510;

  --color-danger-bg:      #fdf0ef;
  --color-danger-border:  #b53f3a;
  --color-danger-text:    #7a201d;

  --color-success-bg:     #edf5ef;
  --color-success-border: #2f7a4a;
  --color-success-text:   #1a4d2e;

  --color-info-bg:        #edf2f8;
  --color-info-border:    #2c4a6e;
  --color-info-text:      #1e3550;

  /* --- Typography --- */
  --font-sans:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono:
    ui-monospace, "SF Mono", "Cascadia Code", "Fira Code",
    Consolas, "Courier New", monospace;

  /* Type scale */
  --text-xs:   0.75rem;     /* 12px */
  --text-sm:   0.875rem;    /* 14px */
  --text-base: 1rem;        /* 16px */
  --text-lg:   1.125rem;    /* 18px */
  --text-xl:   1.25rem;     /* 20px */
  --text-2xl:  1.5rem;      /* 24px */
  --text-3xl:  1.875rem;    /* 30px */
  --text-4xl:  2.25rem;     /* 36px */

  /* Line heights */
  --leading-tight:  1.2;
  --leading-snug:   1.4;
  --leading-normal: 1.6;
  --leading-loose:  1.8;

  /* Font weights */
  --weight-normal:   400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  /* --- Spacing (4px base unit) --- */
  --space-1:  0.25rem;   /* 4px  */
  --space-2:  0.5rem;    /* 8px  */
  --space-3:  0.75rem;   /* 12px */
  --space-4:  1rem;      /* 16px */
  --space-5:  1.25rem;   /* 20px */
  --space-6:  1.5rem;    /* 24px */
  --space-8:  2rem;      /* 32px */
  --space-10: 2.5rem;    /* 40px */
  --space-12: 3rem;      /* 48px */
  --space-16: 4rem;      /* 64px */

  /* --- Layout --- */
  --layout-max:       720px;  /* max readable prose width */
  --layout-wide:      960px;  /* landing hero / full-page layouts */
  --layout-wizard:    560px;  /* wizard step max width */

  /* --- Borders & Shadows --- */
  --radius-sm:   2px;
  --radius-base: 4px;
  --radius-md:   6px;

  --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.10);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.10);

  /* --- Transitions --- */
  --transition-fast:   80ms ease;
  --transition-base:   160ms ease;
  --transition-slow:   280ms ease;

  /* --- Z-index stack --- */
  --z-base:    1;
  --z-raised:  10;
  --z-overlay: 100;
  --z-banner:  200;
}

/* ============================================================
   2. RESET
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video, svg {
  display: block;
  max-width: 100%;
}

/* Remove list styling when a list has a role */
ul[role="list"], ol[role="list"] {
  list-style: none;
}

/* Inherit font in form elements */
input, button, textarea, select {
  font: inherit;
}

/* Remove default button styles */
button {
  cursor: pointer;
  border: none;
  background: none;
}

/* Prevent abbr underlines in Chrome */
abbr[title] {
  text-decoration: underline dotted;
}

/* Remove the default hr appearance */
hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-8) 0;
}

/* ============================================================
   3. BASE TYPOGRAPHY
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}

h1 { font-size: var(--text-3xl); margin-bottom: var(--space-5); }
h2 { font-size: var(--text-2xl); margin-bottom: var(--space-4); }
h3 { font-size: var(--text-xl);  margin-bottom: var(--space-3); }
h4 { font-size: var(--text-lg);  margin-bottom: var(--space-3); }
h5 { font-size: var(--text-base); font-weight: var(--weight-semibold); margin-bottom: var(--space-2); }
h6 { font-size: var(--text-sm);  font-weight: var(--weight-semibold); margin-bottom: var(--space-2); }

p {
  margin-bottom: var(--space-4);
  max-width: 68ch; /* optimal line length */
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--color-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-brand-hover);
}

a:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background-color: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.35em;
}

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background-color: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  padding: var(--space-4);
  overflow-x: auto;
  line-height: var(--leading-loose);
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

strong { font-weight: var(--weight-semibold); }

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

/* Passphrase / code display — monospace, prominent */
.passphrase {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.04em;
  color: var(--color-text-primary);
}

/* ============================================================
   4. LAYOUT PRIMITIVES
   ============================================================ */

/* Page shell — header + main + footer */
.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-main {
  flex: 1;
  padding: var(--space-12) var(--space-6);
}

/* Content containers */
.container {
  max-width: var(--layout-max);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

.container--wide {
  max-width: var(--layout-wide);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.container--narrow {
  max-width: var(--layout-wizard);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

/* Stack: vertical rhythm utility */
.stack > * + * {
  margin-top: var(--space-5);
}

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

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

/* Cluster: horizontal flex wrap */
.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

/* ============================================================
   5a. BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.625rem 1.5rem;
  min-height: 44px;
  min-width: 44px;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1;
  border-radius: var(--radius-base);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast);
  cursor: pointer;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

/* Primary: sage green for "create" actions */
.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-text-inverted);
  border-color: var(--color-accent);
}

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

.btn-primary:active {
  transform: translateY(1px);
}

/* Brand: dark slate-blue for secondary-importance primary actions */
.btn-brand {
  background-color: var(--color-brand);
  color: var(--color-text-inverted);
  border-color: var(--color-brand);
}

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

.btn-brand:active {
  transform: translateY(1px);
}

/* Secondary: outline */
.btn-secondary {
  background-color: transparent;
  color: var(--color-brand);
  border-color: var(--color-brand);
}

.btn-secondary:hover {
  background-color: var(--color-brand-light);
}

/* Danger: for irreversible/destructive actions */
.btn-danger {
  background-color: var(--color-danger-border);
  color: var(--color-text-inverted);
  border-color: var(--color-danger-border);
}

.btn-danger:hover {
  background-color: #8f2f2b;
  border-color: #8f2f2b;
}

/* Ghost: transparent, for tertiary actions */
.btn-ghost {
  background-color: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background-color: var(--color-surface-raised);
  color: var(--color-text-primary);
}

/* Disabled state — applies to all button variants */
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Loading state */
.btn.is-loading {
  position: relative;
  color: transparent; /* hide text */
  pointer-events: none;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  color: var(--color-text-inverted); /* ring color */
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* Small button variant */
.btn--sm {
  padding: 0.375rem 1rem;
  font-size: var(--text-sm);
  min-height: 36px;
}

/* ============================================================
   5b. FORM FIELDS
   ============================================================ */

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-field + .form-field {
  margin-top: var(--space-5);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  letter-spacing: 0.01em;
}

.form-label .required-mark {
  color: var(--color-danger-border);
  margin-left: var(--space-1);
  font-weight: var(--weight-bold);
  aria-label: "required";
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  background-color: var(--color-surface);
  color: var(--color-text-primary);
  font-size: var(--text-base);
  line-height: var(--leading-snug);
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
  appearance: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-text-muted);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px var(--color-brand-light);
}

/* Monospace input — for codes, tokens, passphrases */
.form-input--mono {
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  font-size: var(--text-base);
}

.form-textarea {
  resize: vertical;
  min-height: 5rem;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%235c564e' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

/* Error state */
.form-field.has-error .form-input,
.form-field.has-error .form-textarea,
.form-field.has-error .form-select {
  border-color: var(--color-danger-border);
}

.form-field.has-error .form-input:focus,
.form-field.has-error .form-textarea:focus {
  box-shadow: 0 0 0 3px var(--color-danger-bg);
}

.form-helper {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: var(--leading-snug);
}

.form-error {
  font-size: var(--text-sm);
  color: var(--color-danger-text);
  line-height: var(--leading-snug);
}

/* Character counter */
.char-counter {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: right;
  margin-top: var(--space-1);
}

.char-counter.is-near-limit {
  color: var(--color-warning-text);
}

.char-counter.is-at-limit {
  color: var(--color-danger-text);
  font-weight: var(--weight-medium);
}

/* Fieldset / legend reset */
fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

legend {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-3);
  padding: 0;
}

/* ============================================================
   5c. CARDS
   ============================================================ */

.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  box-shadow: var(--shadow-xs);
}

.card--inset {
  background-color: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  padding: var(--space-4) var(--space-5);
}

.card__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-3);
}

.card__body {
  color: var(--color-text-secondary);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}

/* ============================================================
   5d. CALLOUTS / ALERTS
   ============================================================ */

.callout {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-base);
  border: 1px solid;
  border-left-width: 4px;
  line-height: var(--leading-normal);
  font-size: var(--text-sm);
}

.callout + .callout {
  margin-top: var(--space-4);
}

.callout__title {
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout--info {
  background-color: var(--color-info-bg);
  border-color: var(--color-info-border);
  color: var(--color-info-text);
}

.callout--warning {
  background-color: var(--color-warning-bg);
  border-color: var(--color-warning-border);
  color: var(--color-warning-text);
}

.callout--danger {
  background-color: var(--color-danger-bg);
  border-color: var(--color-danger-border);
  color: var(--color-danger-text);
}

.callout--success {
  background-color: var(--color-success-bg);
  border-color: var(--color-success-border);
  color: var(--color-success-text);
}

/* Persistent session banner (spec §11.4 — "do not close this tab") */
.session-banner {
  position: sticky;
  top: 0;
  z-index: var(--z-banner);
  background-color: var(--color-warning-bg);
  border-bottom: 2px solid var(--color-warning-border);
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  color: var(--color-warning-text);
  font-weight: var(--weight-medium);
  text-align: center;
  line-height: var(--leading-snug);
}

/* ============================================================
   5e. STEP PROGRESS INDICATOR
   ============================================================ */

.step-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.step-indicator__label {
  font-weight: var(--weight-medium);
  color: var(--color-text-primary);
}

.step-indicator__divider {
  flex: 1;
  height: 1px;
  background-color: var(--color-border);
}

/* Step dots — not interactive, visual only */
.step-dots {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-border);
  transition: background-color var(--transition-base);
}

.step-dot.is-complete {
  background-color: var(--color-accent);
}

.step-dot.is-current {
  background-color: var(--color-brand);
  width: 10px;
  height: 10px;
}

/* ============================================================
   5f. ARGON2 WAIT STATE
   ============================================================ */

/*
 * Applied as a class on the <form> element while Argon2 runs.
 * All form inputs become non-interactive. The submit button shows
 * a computing state. An explanatory message appears below.
 */

.form.is-computing {
  pointer-events: none;
}

.form.is-computing .form-input,
.form.is-computing .form-textarea,
.form.is-computing .form-select {
  opacity: 0.6;
}

.computing-notice {
  display: none;
  padding: var(--space-4);
  background-color: var(--color-info-bg);
  border: 1px solid var(--color-info-border);
  border-radius: var(--radius-base);
  font-size: var(--text-sm);
  color: var(--color-info-text);
  margin-top: var(--space-4);
}

.form.is-computing .computing-notice {
  display: block;
}

/* CSS-only animated dots: "Computing..." with trailing dots */
.computing-dots::after {
  content: "";
  display: inline-block;
  animation: computing-pulse 1.4s steps(4, end) infinite;
}

@keyframes computing-pulse {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
  100% { content: ""; }
}

/* ============================================================
   5g. NAVIGATION
   ============================================================ */

.site-nav {
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-6);
}

.site-nav__inner {
  max-width: var(--layout-wide);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
}

.site-nav__wordmark {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-nav__wordmark:hover {
  color: var(--color-brand);
}

.site-nav__links {
  display: flex;
  gap: var(--space-6);
  list-style: none;
}

.site-nav__links a {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  font-weight: var(--weight-medium);
}

.site-nav__links a:hover {
  color: var(--color-text-primary);
}

/* ============================================================
   5h. FOOTER
   ============================================================ */

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-8) var(--space-6);
  margin-top: var(--space-16);
}

.site-footer__inner {
  max-width: var(--layout-wide);
  margin-inline: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.site-footer__links {
  display: flex;
  gap: var(--space-5);
  list-style: none;
}

.site-footer__links a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.site-footer__links a:hover {
  color: var(--color-text-secondary);
  text-decoration: underline;
}

.site-footer__copyright {
  max-width: var(--layout-wide);
  margin: var(--space-3) auto 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ============================================================
   5i. ATTRITION GATE (trigger confirmation)
   ============================================================ */

/*
 * The attrition gate is a type-to-confirm mechanism on the trigger
 * page. The user must type a specific sentence before the submit
 * button activates. This adds friction to prevent accidents.
 */

.attrition-gate {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  background-color: var(--color-surface);
}

.attrition-gate__prompt {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-3);
}

.attrition-gate__phrase {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  background-color: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  line-height: var(--leading-normal);
  user-select: all;
}

.attrition-gate .form-input {
  font-size: var(--text-sm);
}

/* ============================================================
   5j. DATA TABLES (long-form documentation pages)
   ============================================================ */

/*
 * A plain, readable comparison table for long-form documentation pages
 * (currently security.html's "what the server stores" table). Distinct
 * from .codebook-grid, which is a fixed-cell lookup grid meant to be
 * printed — this is ordinary flowing prose content that happens to be
 * tabular, so column widths are not fixed and text wraps normally.
 */

.data-table-wrap {
  overflow-x: auto;
  margin: var(--space-5) 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table th,
.data-table td {
  text-align: left;
  vertical-align: top;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.data-table thead th {
  background: var(--color-surface-raised);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.data-table tbody tr:last-child th,
.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table td p,
.data-table th p {
  margin-bottom: var(--space-2);
  max-width: none;
}

.data-table td p:last-child,
.data-table th p:last-child {
  margin-bottom: 0;
}

/* ============================================================
   5k. STATUS PILL (status.html)
   ============================================================ */

/*
 * A small static label, not a live indicator — status.html is a
 * hand-updated page, not a monitoring dashboard, and nothing here should
 * imply otherwise (no polling, no animation, no auto-refresh).
 */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  padding: 0.2em 0.7em;
  border-radius: 999px;
  white-space: nowrap;
}

.status-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.status-pill--ok {
  background: var(--color-success-bg);
  color: var(--color-success-text);
}

.status-pill--warning {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
}

.status-pill--danger {
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
}

/* ============================================================
   6a. LANDING PAGE HERO
   ============================================================ */

.hero {
  padding: var(--space-16) var(--space-6);
  text-align: center;
}

.hero__eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-5);
}

.hero__headline {
  font-size: var(--text-4xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
  max-width: 20ch;
  margin-inline: auto;
  margin-bottom: var(--space-5);
}

.hero__subhead {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  line-height: var(--leading-normal);
  max-width: 52ch;
  margin-inline: auto;
  margin-bottom: var(--space-10);
}

.hero__ctas {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  flex-wrap: wrap;
}

/* How-it-works section */
.how-it-works {
  padding: var(--space-12) var(--space-6);
  border-top: 1px solid var(--color-border);
}

.how-it-works__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-6);
  margin-top: var(--space-8);
}

.how-step {
  padding: var(--space-5);
}

.how-step__number {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.how-step__title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
}

.how-step__body {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-normal);
  max-width: 100%;
}

/* Generic "band" section with the same top divider + vertical rhythm as
   .how-it-works, for the landing page's privacy/pricing/trustee sections
   (previously each repeated this as an inline style="" attribute). */
.section--divided {
  padding: var(--space-12) var(--space-6);
  border-top: 1px solid var(--color-border);
}

/* Pricing cards (landing page) */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-5);
}

/* Single-plan variant: one centered card instead of a multi-column grid
   (deadkey.net moved to flat pricing in SPEC v0.5.1 — no more tiers). */
.pricing-grid--single {
  grid-template-columns: minmax(0, 1fr);
  max-width: 420px;
  margin-inline: auto;
}

.card--brand-outline {
  border-color: var(--color-brand);
}

.pricing-card__eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.pricing-card__eyebrow--brand {
  color: var(--color-brand);
}

.pricing-card__price {
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-1);
}

.pricing-card__unit {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-5);
}

.pricing-card__features {
  list-style: none;
  display: grid;
  gap: var(--space-2);
  padding: 0;
  margin-bottom: var(--space-6);
}

.pricing-card__features li {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

/* ============================================================
   6b. WIZARD LAYOUT
   ============================================================ */

.wizard {
  max-width: var(--layout-wizard);
  margin-inline: auto;
  padding: var(--space-10) var(--space-4);
}

.wizard__header {
  margin-bottom: var(--space-8);
}

.wizard__title {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-2);
}

.wizard__description {
  color: var(--color-text-secondary);
  font-size: var(--text-base);
  margin-bottom: 0;
}

.wizard__content {
  margin-bottom: var(--space-8);
}

.wizard__actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
}

.wizard__actions--end {
  justify-content: flex-end;
}

/* Small uppercase eyebrow label above a wizard__title (CSP pass: replaces
   a repeated inline style="" block that appeared identically on cancel.html
   and trigger.html). */
.wizard__eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

/* ============================================================
   6c. PRINT SHEET COMPONENTS
   ============================================================ */

/*
 * Print sheets are rendered by the client after successful setup.
 * They are designed to look clean both on-screen (for preview)
 * and in print. The .screen-only class hides content from print.
 */

.print-sheet {
  max-width: 680px;
  margin-inline: auto;
  padding: var(--space-8);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
}

/* :not(.is-hidden) on both sides matters: print-trusted.html keeps every
   sheet variant in the DOM at once and toggles .is-hidden to show only one
   at a time (see print-trusted.js). A bare ".print-sheet + .print-sheet"
   selector matches on DOM adjacency regardless of render state, so the
   visible sheet — always preceded in the DOM by a hidden one — would pick up
   this rule (and the print-media page-break-before below) even though there
   is nothing actually rendered before it. In print that produced a blank
   leading page. Scoping to :not(.is-hidden) siblings fixes it without
   affecting create.js's dynamically rendered papers, which use the separate
   .paper class instead. */
.print-sheet:not(.is-hidden) + .print-sheet:not(.is-hidden) {
  margin-top: var(--space-8);
}

.print-sheet__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--color-text-primary);
}

.print-sheet__wordmark {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  letter-spacing: 0.02em;
  color: var(--color-text-primary);
  text-transform: uppercase;
}

.print-sheet__type {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

/* Sensitive marker on Owner Paper */
.print-sheet__private-marker {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-danger-text);
  border: 1px solid var(--color-danger-border);
  border-radius: var(--radius-sm);
  padding: 0.15em 0.5em;
  margin-top: var(--space-1);
}

.print-sheet__intro {
  margin-bottom: var(--space-5);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--color-text-secondary);
}

/* Right-aligned header block (e.g. "Trustee copy" + Trustee ID) */
.print-sheet__header-right { text-align: right; }

/* Small muted annotation next to a print-data value */
.print-data__annotation {
  font-size: var(--text-sm);
  font-weight: var(--weight-normal);
  color: var(--color-text-muted);
}

/* A divided sub-section within a print sheet (e.g. "Instructions from the
   owner" notes block) */
.print-sheet__section {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}

.print-sheet__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.print-sheet__note-preview {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-style: italic;
}

.print-sheet__footer {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-4);
}

.print-sheet__footer-note {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0;
  max-width: 36ch;
  line-height: var(--leading-normal);
}

.print-sheet__footer-tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0;
  white-space: nowrap;
}

/* Data fields on the print sheet */
.print-data {
  display: grid;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.print-data__row {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: var(--space-4);
  align-items: baseline;
}

.print-data__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.print-data__value {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  letter-spacing: 0.02em;
  word-break: break-all;
}

/* Passphrase box — dashed border, prominent */
.print-passphrase-box {
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius-base);
  padding: var(--space-5) var(--space-6);
  margin: var(--space-5) 0;
  background-color: var(--color-surface-raised);
}

.print-passphrase-box__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.print-passphrase-box__words {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: 0.04em;
  color: var(--color-text-primary);
  line-height: var(--leading-loose);
  word-spacing: 0.5em;
}

/* v0.7 codebook grid: a 10×10 lookup table shared by the dynamically
   rendered Recovery Sheets (create.js's .paper markup) and the static
   print-trusted.html / codebook-template.html previews (.print-sheet
   markup) — defined here, in the shared stylesheet, rather than in either
   page's own CSS, so both call sites stay visually identical. Row label =
   tens digit, column label = ones digit, so the printed coordinate ("00"
   .."99") IS the (row, column) pair read directly off the table. */
.codebook-grid {
  border-collapse: collapse;
  width: 100%;
  margin: var(--space-4) 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}
.codebook-grid th,
.codebook-grid td {
  border: 1px solid var(--color-border-strong);
  text-align: center;
  padding: 0.3em 0.4em;
  width: 2.4em;
}
.codebook-grid th {
  background: var(--color-surface-raised);
  font-weight: 700;
}
.codebook-grid__row-label { background: var(--color-surface-raised); font-weight: 700; }

/* Blank template variant (codebook-template.html): taller empty cells, room
   for a handwritten digit. */
.codebook-grid--blank td { height: 2.2em; }

/* Trustee write-in lines */
.trustee-lines {
  margin-top: var(--space-5);
  display: grid;
  gap: var(--space-4);
}

.trustee-line {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: var(--space-4);
  align-items: center;
}

.trustee-line__id {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
}

.trustee-line__blank {
  border-bottom: 1px solid var(--color-text-primary);
  height: 1.5em;
}

/* Instructions section (screen-only on print pages) */
.screen-only-instructions {
  margin-top: var(--space-12);
  padding: var(--space-6);
  background-color: var(--color-info-bg);
  border: 1px solid var(--color-info-border);
  border-radius: var(--radius-md);
}

.screen-only-instructions h2 {
  font-size: var(--text-xl);
  color: var(--color-info-text);
  margin-bottom: var(--space-4);
}

.screen-only-instructions p,
.screen-only-instructions li {
  color: var(--color-info-text);
  font-size: var(--text-sm);
}

.screen-only-instructions ol,
.screen-only-instructions ul {
  padding-left: var(--space-6);
  margin-top: var(--space-3);
}

.screen-only-instructions li {
  margin-bottom: var(--space-2);
  line-height: var(--leading-normal);
}

/* A numbered "what happens next" list (trigger.html confirm step). Replaces
   a block of identical inline style="" attributes repeated on every <li>. */
.step-list {
  list-style: none;
  display: grid;
  gap: var(--space-3);
  padding: 0;
}
.step-list__item {
  display: grid;
  grid-template-columns: 1.5rem 1fr;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}
.step-list__num {
  font-family: var(--font-mono);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}

/* ============================================================
   7. UTILITY CLASSES
   ============================================================ */

/* Text utilities */
.text-xs      { font-size: var(--text-xs); }
.text-sm      { font-size: var(--text-sm); }
.text-base    { font-size: var(--text-base); }
.text-lg      { font-size: var(--text-lg); }
.text-xl      { font-size: var(--text-xl); }
.text-2xl     { font-size: var(--text-2xl); }
.text-3xl     { font-size: var(--text-3xl); }
.text-muted   { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-primary { color: var(--color-text-primary); }
.text-brand   { color: var(--color-brand); }
.text-mono    { font-family: var(--font-mono); }
.font-medium  { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-italic  { font-style: italic; }
.text-nowrap  { white-space: nowrap; }
.uppercase    { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.08em; }

/* Spacing utilities */
.mt-0  { margin-top: 0; }
.mt-1  { margin-top: var(--space-1); }
.mt-2  { margin-top: var(--space-2); }
.mt-3  { margin-top: var(--space-3); }
.mt-4  { margin-top: var(--space-4); }
.mt-5  { margin-top: var(--space-5); }
.mt-6  { margin-top: var(--space-6); }
.mt-8  { margin-top: var(--space-8); }
.mb-0  { margin-bottom: 0; }
.mb-1  { margin-bottom: var(--space-1); }
.mb-2  { margin-bottom: var(--space-2); }
.mb-3  { margin-bottom: var(--space-3); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-5  { margin-bottom: var(--space-5); }
.mb-6  { margin-bottom: var(--space-6); }
.mb-8  { margin-bottom: var(--space-8); }
.pt-4  { padding-top: var(--space-4); }
.pt-5  { padding-top: var(--space-5); }
.mx-auto { margin-inline: auto; }

/* Layout utilities */
.w-full { width: 100%; }
.list-none { list-style: none; padding: 0; }
.border-top { border-top: 1px solid var(--color-border); }
.flex { display: flex; }
.grid { display: grid; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.max-w-prose { max-width: 56ch; }

/* A full-width button whose content is centered — replaces the repeated
   style="width: 100%; justify-content: center;" on primary CTA buttons. */
.btn--block { width: 100%; justify-content: center; }

/* Visibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Generic hidden-by-default toggle target. Elements using this class start
   hidden; JS may still switch them to visible via el.style.display = "..."
   (a CSSOM property write, not an HTML attribute — unaffected by CSP
   style-src), which takes precedence over this class's display:none. */
.is-hidden { display: none; }

/* Screen-only: hidden in print (see @media print below) */
.screen-only { /* visible by default — hidden via @media print */ }

/* Print-only: hidden on screen */
.print-only {
  display: none;
}

/* Dividers */
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-8) 0;
}

/* ============================================================
   8. @MEDIA PRINT
   ============================================================ */

@media print {
  /* Reset body for print */
  body {
    background: #ffffff;
    color: #000000;
    font-size: 11pt;
    line-height: 1.5;
    font-family: var(--font-sans);
    margin: 0;
    padding: 0;
  }

  /* Hide all non-print elements */
  .site-nav,
  .site-footer,
  .session-banner,
  .screen-only,
  .screen-only-instructions,
  .wizard__actions,
  .btn,
  nav,
  footer {
    display: none !important;
  }

  /* Show print-only elements */
  .print-only {
    display: block;
  }

  /* Print page — ensure clean rendering */
  .print-sheet {
    max-width: 100%;
    width: 6.5in;
    margin: 0 auto;
    padding: 0;
    border: none;
    box-shadow: none;
    border-radius: 0;
    page-break-inside: avoid;
  }

  /* See the screen-media rule above for why :not(.is-hidden) is required
     here — without it, print-trusted.html's single visible sheet gets an
     unwanted page-break-before (it always has a hidden .print-sheet sibling
     immediately before it in the DOM), producing a blank first page when
     printing or saving as PDF. */
  .print-sheet:not(.is-hidden) + .print-sheet:not(.is-hidden) {
    page-break-before: always;
    margin-top: 0;
  }

  /* Force black text, no backgrounds */
  .print-sheet *,
  .print-sheet__header,
  .print-data__label,
  .print-data__value,
  .print-passphrase-box__words {
    color: #000000 !important;
    background: transparent !important;
    text-shadow: none !important;
  }

  /* Print sheet header */
  .print-sheet__header {
    border-bottom: 2px solid #000000;
    padding-bottom: 0.25in;
    margin-bottom: 0.25in;
  }

  .print-sheet__wordmark {
    font-size: 14pt;
    font-weight: 700;
  }

  .print-sheet__type {
    font-size: 9pt;
    color: #444444 !important;
  }

  .print-sheet__private-marker {
    color: #000000 !important;
    border-color: #000000 !important;
    font-size: 8pt;
  }

  /* Intro text */
  .print-sheet__intro {
    font-size: 10pt;
    color: #222222 !important;
    margin-bottom: 0.2in;
  }

  /* Data fields */
  .print-data {
    gap: 0.12in;
    margin-bottom: 0.2in;
  }

  .print-data__row {
    grid-template-columns: 9rem 1fr;
  }

  .print-data__label {
    font-size: 10pt;
    color: #444444 !important;
    font-weight: 600;
  }

  .print-data__value {
    font-size: 11pt;
    font-weight: 700;
    letter-spacing: 0.03em;
  }

  /* v0.7 codebook grid — crisp black borders, avoid breaking mid-table */
  .codebook-grid,
  .codebook-grid th,
  .codebook-grid td {
    border-color: #000000 !important;
  }
  .codebook-grid { page-break-inside: avoid; }

  /* Passphrase box — the most critical element */
  .print-passphrase-box {
    border: 2px dashed #000000;
    background: transparent !important;
    padding: 0.15in 0.2in;
    margin: 0.15in 0;
  }

  .print-passphrase-box__label {
    font-size: 8pt;
    color: #444444 !important;
    margin-bottom: 0.1in;
  }

  .print-passphrase-box__words {
    font-size: 14pt;
    font-weight: 700;
    letter-spacing: 0.04em;
    word-spacing: 0.4em;
    line-height: 2;
  }

  /* Trustee lines */
  .trustee-lines {
    gap: 0.15in;
  }

  .trustee-line__id {
    font-size: 10pt;
  }

  .trustee-line__blank {
    border-bottom: 1px solid #000000;
  }

  /* Ensure links don't show URL in print */
  a[href]::after {
    content: none;
  }

  /* Suppress shadows and decorative borders */
  * {
    box-shadow: none !important;
  }

  /* Avoid breaking inside key data areas */
  .print-data,
  .print-passphrase-box,
  .trustee-lines {
    page-break-inside: avoid;
  }

  /* Page margins */
  @page {
    size: letter;
    margin: 0.75in 1in;
  }
}

/* ============================================================
   9. @MEDIA (PREFERS-REDUCED-MOTION)
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }

  /* Replace animated computing dots with static text */
  .computing-dots::after {
    content: "...";
    animation: none;
  }

  /* Replace button spinner with static label */
  .btn.is-loading::after {
    animation: none;
    border-width: 0;
  }
}

/* ============================================================
   10. RESPONSIVE OVERRIDES
   ============================================================ */

/* Tablet and below */
@media (max-width: 768px) {
  .page-main {
    padding: var(--space-8) var(--space-4);
  }

  .hero {
    padding: var(--space-10) var(--space-4);
  }

  .hero__headline {
    font-size: var(--text-3xl);
  }

  .hero__subhead {
    font-size: var(--text-base);
  }

  .hero__ctas {
    flex-direction: column;
    align-items: center;
  }

  .how-it-works__grid {
    grid-template-columns: 1fr;
  }

  .site-nav__links {
    display: none; /* mobile nav deferred to v2 */
  }

  .print-data__row {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }

  .print-data__label {
    font-size: var(--text-xs);
  }

  .wizard__actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .wizard__actions .btn {
    width: 100%;
    justify-content: center;
  }

  .card {
    padding: var(--space-4);
  }
}

/* Small phones */
@media (max-width: 480px) {
  .hero__headline {
    font-size: var(--text-2xl);
  }

  .step-indicator {
    flex-wrap: wrap;
  }

  .print-passphrase-box__words {
    font-size: var(--text-base);
    word-spacing: normal;
    word-break: break-word;
  }
}
