/* =============================================================================
   VoiceFill — design system
   Light theme. Brand blue #3b82f6. Syne for headings, DM Sans for body,
   JetBrains Mono for monospace. Soft shadows, generous whitespace.
   ============================================================================= */

:root {
  /* Brand */
  --brand: #3b82f6;
  --brand-hover: #2563eb;
  --brand-glow: rgba(59, 130, 246, 0.18);
  --brand-faint: rgba(59, 130, 246, 0.08);
  --brand-light: rgba(59, 130, 246, 0.12);

  /* Surfaces */
  --bg: #f4f7ff;
  --surface: #ffffff;
  --surface-2: #f8fafc;

  /* Borders */
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* Text */
  --text: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  /* Semantic */
  --good: #10b981;
  --good-faint: rgba(16, 185, 129, 0.12);
  --bad: #ef4444;
  --warn: #f59e0b;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 1px 3px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 4px 6px rgba(15, 23, 42, 0.05), 0 24px 60px rgba(15, 23, 42, 0.10);
  --shadow-fab: 0 8px 24px rgba(59, 130, 246, 0.30), 0 2px 6px rgba(59, 130, 246, 0.20);
  --ring-focus: 0 0 0 4px var(--brand-glow);

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* Type */
  --font-heading: 'Syne', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 160ms;
  --t-base: 220ms;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-feature-settings: "ss01", "cv11";
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.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;
}

.is-hidden { display: none !important; }

/* =============================================================================
   Top bar
   ============================================================================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: rgba(244, 247, 255, 0.85);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.brand-mark {
  /* Wrapper just sizes/positions the inline SVG mark — the SVG itself owns
     its blue rounded-square fill and the white mic glyph. Subtle drop
     shadow stays so the mark reads as a tile, not a flat sticker. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  filter: drop-shadow(0 2px 8px var(--brand-glow));
}
.brand-mark svg { display: block; width: 28px; height: 28px; }
.brand-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--text);
}
/* InstantHub wordmark: "Instant" inherits the existing dark text token,
   "Hub" picks up Brand Blue. Spans live inside .brand-name so the wordmark
   weight + size + tracking come from one place. */
.wordmark-instant { color: var(--text); }
.wordmark-hub     { color: var(--brand); }
.topbar-meta { display: inline-flex; align-items: center; gap: 10px; }

/* (.status-pill rules removed — the "Demo mode" badge and "session XXXX"
   indicator they styled were stripped from the topbar; the icon-button
   row is now the only thing in .topbar-meta.) */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }

/* User chip (Phase 3A.1). Sits in .topbar-meta after the icon row. */
.user-chip { position: relative; }
.user-chip-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.user-chip-button:hover { background: var(--surface); }
.user-chip-button:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.user-chip-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand, #3b82f6);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.user-chip-label { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 6px;
  z-index: 1000;
}
.user-chip-menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 13px;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
}
.user-chip-menu-item:hover { background: rgba(0,0,0,0.05); }

/* Sign-out row inside Settings modal */
.settings-account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}
.settings-account-email {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.settings-signout {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.settings-signout:hover { background: rgba(0,0,0,0.04); border-color: var(--text-muted); }

/* =============================================================================
   Quota chip (Phase 3A.2 part 3E)
   ============================================================================= */
.quota-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  margin-right: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  background: transparent;
  white-space: nowrap;
}
.quota-chip.is-free-available {
  color: var(--brand, #3b82f6);
  border-color: color-mix(in srgb, var(--brand, #3b82f6) 30%, transparent);
  background: color-mix(in srgb, var(--brand, #3b82f6) 6%, transparent);
}
.quota-chip.is-exhausted {
  color: #b91c1c;
  border-color: rgba(185,28,28,0.3);
  background: rgba(254,226,226,0.6);
}
.quota-chip.is-exhausted:hover {
  background: rgba(254,226,226,0.95);
}
.quota-chip.is-paid {
  color: var(--text);
  border-color: var(--border);
  background: var(--surface, #fff);
}

/* =============================================================================
   Paywall modal (Phase 3A.2 part 3D)
   ============================================================================= */
.paywall-card { max-width: 460px; }
.paywall-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  margin: 0 0 16px;
  padding: 0 4px;
}

/* =============================================================================
   Onboarding tooltip (Phase 3A.2 part 4)
   ============================================================================= */
.onboarding-tooltip {
  position: fixed;
  z-index: 1100;
  max-width: 280px;
  padding: 14px 16px 10px;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.18), 0 0 0 4px color-mix(in srgb, var(--brand, #3b82f6) 8%, transparent);
  animation: onboarding-fade-in 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes onboarding-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.onboarding-tooltip-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand, #3b82f6);
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.onboarding-tooltip-body {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}
.onboarding-tooltip-footer {
  display: flex;
  justify-content: flex-end;
}
.onboarding-tooltip-dismiss {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 4px;
}
.onboarding-tooltip-dismiss:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.onboarding-tooltip-arrow {
  /* Tiny up-pointing triangle at the top of the tooltip. Repositioned via
     data-actual-placement; only "top" arrow needed since all 3 placements
     point at the target FROM ABOVE/BELOW with the body anchored under it
     (bottom-* placements show the arrow on top). */
  position: absolute;
  top: -6px;
  left: 24px;
  width: 12px;
  height: 12px;
  background: var(--surface, #fff);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  transform: rotate(45deg);
}
.onboarding-tooltip[data-actual-placement="top-center"] .onboarding-tooltip-arrow {
  top: auto;
  bottom: -6px;
  left: 50%;
  margin-left: -6px;
  border-top: 0;
  border-left: 0;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.onboarding-tooltip[data-actual-placement="bottom-center"] .onboarding-tooltip-arrow {
  left: 50%;
  margin-left: -6px;
}
.onboarding-tooltip[data-actual-placement="bottom-right"] .onboarding-tooltip-arrow {
  left: auto;
  right: 16px;
}

/* =============================================================================
   App shell
   ============================================================================= */

.app-shell {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.app-shell.is-empty .workspace { display: none; }
.app-shell:not(.is-empty) .hero { display: none; }

/* =============================================================================
   HERO (empty state)
   ============================================================================= */

.hero {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 96px;
  text-align: center;
}
.hero-inner {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}
.hero-headline {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.04;
  letter-spacing: -0.025em;
  color: var(--text);
}
.hero-subhead {
  margin: 0;
  font-size: clamp(16px, 1.4vw, 19px);
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 540px;
}

/* 3-step explainer */
.steps {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
}
.step {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.step-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--brand-faint);
  color: var(--brand);
}
.step-content { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.step-title { font-family: var(--font-heading); font-weight: 600; font-size: 13px; color: var(--text); }
.step-desc { font-size: 12px; color: var(--text-muted); }
.step-sep {
  list-style: none;
  display: inline-flex;
  align-items: center;
  color: var(--text-dim);
}

.hero-foot {
  margin: 24px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}

/* =============================================================================
   WORKSPACE (filled state)
   ============================================================================= */

.workspace {
  flex: 1 1 auto;
  min-height: 0;
  padding: 24px 32px 160px;
}
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(360px, 1fr);
  gap: 24px;
  align-items: start;
  max-width: 1480px;
  margin: 0 auto;
}

/* ---- Form preview column ---- */
.preview-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.preview-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px;
}
.preview-eyebrow {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.preview-sub { font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.preview-body { display: flex; flex-direction: column; gap: 20px; }

.form-block { display: flex; flex-direction: column; gap: 16px; }
.form-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.01em;
  padding: 4px 4px 0;
}

/* Each page is a white card */
.page-wrap {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  transition: box-shadow var(--t-base) var(--ease-out);
}
.page-wrap:hover { box-shadow: var(--shadow-lg); }
.page-wrap img { display: block; width: 100%; height: auto; user-select: none; }
.page-overlay { position: absolute; inset: 0; pointer-events: none; }

/* Schedule A page-break label */
.sa-continuation { margin-top: 0; }
.sa-page-break {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 6px 4px 2px;
  color: var(--text-dim);
  font-family: var(--font-heading);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sa-page-break::before, .sa-page-break::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Field overlays drawn on top of the page image. Inherit the printed-form
   look — transparent fill, no resting border, brand-blue ring on focus. */
.field-box {
  position: absolute;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 3px;
  display: flex;
  align-items: center;
  padding: 0 4px;
  font: 12px/1.1 var(--font-body);
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}

input.field-box, textarea.field-box {
  display: block;
  font-family: inherit;
  color: #0f172a;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  cursor: text;
  resize: none;
  box-sizing: border-box;
  pointer-events: auto;
  background: transparent;
}
input.field-box::placeholder, textarea.field-box::placeholder { color: rgba(15,23,42,0.32); }
input.field-box:hover, textarea.field-box:hover {
  background: rgba(59, 130, 246, 0.04);
  border-color: var(--brand-light);
}
input.field-box:focus, textarea.field-box:focus {
  border-color: var(--brand);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 3px var(--brand-glow);
  z-index: 5;
}
.field-box.is-readonly { pointer-events: none; cursor: default; }
.field-box.is-filled {
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  font-weight: 500;
}
/* Form-overlay checkboxes (created as <div role="checkbox"> in createFieldBox).
   The page-overlay parent has pointer-events:none, so children must opt back
   in or clicks fall through to the page image. Black border + black ✓ for
   the legal-document feel — explicit, neutral, not brand-blue. */
.field-box.is-checkbox {
  justify-content: center;
  padding: 0;
  background: transparent;
  border: 1.5px solid var(--text);
  border-radius: 3px;
  pointer-events: auto;
  cursor: pointer;
}
.field-box.is-checkbox:hover { background: rgba(15, 23, 42, 0.04); }
.field-box.is-checkbox:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--brand-glow);
}
.field-box.is-checkbox.is-filled::after {
  content: "✓";
  color: var(--text);
  font-weight: 800;
  font-size: 18px;
  line-height: 1;
}
.field-box.is-schedule-a {
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: break-word;
  overflow: hidden;
  text-overflow: clip;
  display: block;
  padding: 8px 10px;
  line-height: 1.28;
  font-family: var(--font-body);
}

.field-box.is-signature {
  background: repeating-linear-gradient(-45deg, rgba(59,130,246,0.06) 0 4px, transparent 4px 10px);
  border-color: rgba(148,163,184,0.45);
}

/* Skipped fields — fields the canonical mapping explicitly skips (e.g.
   helper/instruction blanks, page-2 Tel/Fax/Date slots on Form 320).
   The overlay input still exists and is fully clickable / typeable, but
   resting visual decoration is hidden so the preview reads like a clean
   form rather than a striped grid. Hover gets a barely-there border;
   focus gets a thin neutral border so the agent can see where they're
   typing. Brand-blue rings are reserved for primary fields. */
.field-box.is-skipped {
  border: 1px dashed transparent !important;
  background: transparent !important;
  box-shadow: none !important;
}
/* Hover: dashed brand-blue at 30% opacity so the agent can SEE where the
   bbox is when scanning the form. Previous 10% was too invisible — users
   thought lines were undetected. Still subtle enough to not clutter. */
.field-box.is-skipped:hover {
  border-color: rgba(59, 130, 246, 0.45) !important;
  background: rgba(59, 130, 246, 0.04) !important;
}
.field-box.is-skipped:focus {
  border-style: solid !important;
  border-color: var(--brand) !important;
  background: rgba(255, 255, 255, 0.7) !important;
  box-shadow: 0 0 0 2px var(--brand-glow) !important;
}
input.field-box.is-skipped::placeholder { color: transparent; }

/* Fill-flash: brief amber/brand glow on voice fill */
.field-box.flash {
  animation: field-flash 720ms var(--ease-out);
  z-index: 5;
}
@keyframes field-flash {
  0%   { box-shadow: 0 0 0 0 var(--brand-glow); border-color: var(--brand); background: rgba(59, 130, 246, 0.10); }
  60%  { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0); border-color: var(--brand); }
  100% { box-shadow: none; }
}

/* While recording, dim the form preview so the right-side fills feel dramatic */
body.is-recording .preview-col,
body.is-processing .preview-col { opacity: 0.78; transition: opacity var(--t-base) var(--ease-out); }
body.is-recording .fields-col,
body.is-processing .fields-col { box-shadow: var(--shadow-lg), 0 0 0 2px var(--brand-light); }

/* =============================================================================
   FIELDS PANEL (right column)
   ============================================================================= */

.fields-col {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  max-height: calc(100vh - 112px);
  min-height: 0;
  overflow: hidden;
  transition: box-shadow var(--t-base) var(--ease-out);
}

.fields-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.fields-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.fields-title {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.015em;
  color: var(--text);
}
.fields-stats {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.fields-help {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
}
.fields-search {
  position: relative;
  display: flex;
  align-items: center;
}
.fields-search svg {
  position: absolute;
  left: 12px;
  color: var(--text-dim);
  pointer-events: none;
}
.fields-search input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.fields-search input::placeholder { color: var(--text-dim); }
.fields-search input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: var(--ring-focus);
}

.fields-body {
  padding: 8px 6px 16px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.fields-body::-webkit-scrollbar { width: 8px; }
.fields-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
.fields-body::-webkit-scrollbar-track { background: transparent; }

/* Generate button (in panel header) */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--brand);
  background: var(--brand);
  color: white;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.005em;
  box-shadow: 0 2px 8px var(--brand-glow);
  transition: background var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), transform 60ms;
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  box-shadow: 0 4px 14px var(--brand-glow);
}
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.btn-primary.is-pulse { animation: btn-pulse 1400ms var(--ease-out); }
@keyframes btn-pulse {
  0%   { box-shadow: 0 0 0 0 var(--brand-glow); }
  35%  { box-shadow: 0 0 0 12px rgba(59, 130, 246, 0); }
  100% { box-shadow: 0 2px 8px var(--brand-glow); }
}

/* Empty state inside the panel */
.empty-state {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 32px 16px;
}

/* ---- Categories ---- */
.checklist-form { padding: 0 6px; }
.checklist-form-title {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 16px 6px 6px;
}

.category {
  margin: 6px 0;
}
.category-header {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 10px;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--text);
  text-align: left;
  transition: background var(--t-fast) var(--ease-out);
}
.category-header:hover { background: var(--surface-2); }
.category-header:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.category-caret {
  color: var(--text-muted);
  transition: transform var(--t-base) var(--ease-out);
}
.category.is-collapsed .category-caret { transform: rotate(-90deg); }
.category-label {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.01em;
  color: var(--text);
}
.category-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-variant-numeric: tabular-nums;
}
.category.is-complete .category-count { color: var(--good); border-color: var(--good-faint); background: var(--good-faint); }

.category-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  max-height: 9999px;
  transition: max-height var(--t-base) var(--ease-out), opacity var(--t-base) var(--ease-out);
}
.category.is-collapsed .category-body {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* ---- Concept rows ---- */
.field-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 10px;
  border-radius: var(--r-sm);
  transition: background var(--t-fast) var(--ease-out);
}
.field-row:hover { background: var(--surface-2); }

.field-check {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  border-radius: 5px;
  border: 1.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 12px;
  font-weight: 700;
  transition: background var(--t-base), border-color var(--t-base), color var(--t-base);
}
.field-row.is-filled .field-check {
  background: var(--good);
  border-color: var(--good);
  color: white;
}
.field-row.is-filled .field-check::after { content: "✓"; }

.field-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Multi-form session: deduped concept rows show a "Fills: 100, 320, 801"
   chip next to the label so the agent knows which forms a single edit
   propagates to. Same pattern reused in the Auto-filled section. */
.field-label-wrap, .autofilled-label-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.field-label-wrap .field-label { flex: 0 1 auto; min-width: 0; }
.autofilled-label-wrap .autofilled-label { flex: 0 1 auto; min-width: 0; }
.fills-badge {
  flex: 0 0 auto;
  margin-left: auto;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  text-transform: uppercase;
  white-space: nowrap;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
}
.concept-row.is-required .field-label::after {
  content: "•";
  color: var(--brand);
  margin-left: 6px;
  font-size: 14px;
}

.field-type, .concept-hint {
  font-size: 11.5px;
  color: var(--text-dim);
  font-style: normal;
  letter-spacing: 0;
  text-transform: none;
}

.field-input {
  margin-top: 4px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.field-input::placeholder { color: var(--text-dim); }
.field-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring-focus);
}
.field-row.is-filled .field-input { border-color: rgba(16, 185, 129, 0.45); background: var(--surface); }

/* Right-panel checkbox concepts (Form 320 representation section).
   Replaces the standard `.field-check` + label + input layout with a
   clickable button that mirrors the form-overlay checkbox state. */
.field-row.is-checkbox-concept { grid-template-columns: 22px 1fr; align-items: start; }
.concept-checkbox {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  border-radius: 5px;
  border: 1.5px solid var(--text);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  cursor: pointer;
  padding: 0;
  transition: background var(--t-base), color var(--t-base);
}
.concept-checkbox:hover { background: rgba(15, 23, 42, 0.04); }
.concept-checkbox:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.concept-checkbox.is-checked {
  background: var(--surface);
  border-color: var(--text);
  color: var(--text);
}
.concept-checkbox-tick { display: block; }
.field-row.is-checkbox-concept .field-label {
  white-space: normal;        /* let long checkbox labels wrap */
  font-weight: 500;
  font-size: 13px;
  line-height: 1.4;
}

/* Voice fill highlight */
.field-row.is-just-filled {
  animation: row-flash 800ms var(--ease-out);
}
@keyframes row-flash {
  0%   { background: var(--brand-light); }
  100% { background: transparent; }
}

/* ---- Pills (clauses, chattels, rentals) ---- */
.pills-section { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.pills-section-label {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform 80ms;
}
.pill:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-faint);
}
.pill:active { transform: translateY(1px); }
.pill:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.pill.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}
.pill.is-active .pill-eye { color: rgba(255, 255, 255, 0.85); }
.pill.is-active .pill-eye:hover { color: white; background: rgba(255, 255, 255, 0.16); }

.pill-label { display: inline-block; }
.pill-eye {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 2px;
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
}
.pill-eye:hover { color: var(--brand); background: var(--brand-light); }
.pill-eye:focus-visible { outline: none; box-shadow: var(--ring-focus); }

.pill.is-custom-clause {
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
}
.pill.is-custom-clause:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-faint);
}
.pill-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
}

/* "Manual edits" badge above SA textarea */
.sa-manual-badge {
  align-self: flex-start;
  margin-top: 4px;
  padding: 4px 12px;
  background: var(--brand);
  border: 1px solid var(--brand);
  color: white;
  border-radius: var(--r-pill);
  font-family: var(--font-heading);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background var(--t-fast), box-shadow var(--t-fast);
}
.sa-manual-badge:hover { background: var(--brand-hover); box-shadow: 0 4px 10px var(--brand-glow); }
.sa-manual-badge:focus-visible { outline: none; box-shadow: var(--ring-focus); }

/* ---- Auto-filled section ---- */
.autofilled-section {
  margin-top: 18px;
  padding: 14px 6px 8px;
  border-top: 1px solid var(--border);
}
.autofilled-title { margin: 0 6px 8px; }
.autofilled-row {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--text-muted);
  transition: background var(--t-fast);
}
.autofilled-row:hover { background: var(--surface-2); }
.autofilled-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
}
.autofilled-dot.is-profile { background: var(--brand); }
.autofilled-dot.is-hardcoded { background: var(--warn); }
.autofilled-label { color: var(--text-muted); }
.autofilled-value {
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text);
  font-weight: 500;
  text-align: right;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 4px 8px;
  width: 60%;
  min-width: 0;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.autofilled-value:hover { border-color: var(--border); background: var(--surface); }
.autofilled-value:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: var(--ring-focus);
  text-align: left;
}

/* =============================================================================
   FLOATING MIC DOCK
   ============================================================================= */

.mic-dock {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}
.mic-dock > * { pointer-events: auto; }

.mic-transcript {
  display: none;
  max-width: 720px;
  min-width: 320px;
  padding: 12px 18px;
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}
body.is-recording .mic-transcript,
body.is-processing .mic-transcript { display: block; animation: transcript-in 200ms var(--ease-out); }
@keyframes transcript-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.mic-transcript.is-interim { color: var(--text-muted); font-style: italic; }
.transcript-placeholder { color: var(--text-dim); }

.mic-rec-pill {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 10px;
  background: #0f172a;
  color: white;
  border-radius: var(--r-pill);
  font-family: var(--font-heading);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: var(--shadow-md);
}
.mic-rec-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bad);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  animation: rec-pulse 1.2s ease-in-out infinite;
}
@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  50%      { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}
body.is-recording .mic-rec-pill { display: inline-flex; }

/* Parse-state indicator: shown between transcript-display and animateFill so
   agents have a "filling fields…" cue during the silent /api/parse round trip
   (~3-5s on Claude). Visibility is JS-controlled via .is-active — kept off the
   `body.is-processing` selector so transcribe-only and animate-only phases
   don't show the parse copy. The dot reuses the rec-pulse animation pattern
   for consistency with the recording indicator. */
.mic-parse-status {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--r-pill);
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-sm);
}
.mic-parse-status.is-active { display: inline-flex; }
.mic-parse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.55);
  animation: parse-pulse 1.4s ease-in-out infinite;
}
@keyframes parse-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.55); transform: scale(1); }
  50%      { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0); transform: scale(1.1); }
}

.mic-fab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: none;
  background: var(--brand);
  color: white;
  box-shadow: var(--shadow-fab);
  cursor: pointer;
  transition: transform var(--t-base) var(--ease-out), background var(--t-fast), box-shadow var(--t-base) var(--ease-out);
}
.mic-fab:hover:not(:disabled) {
  background: var(--brand-hover);
  transform: scale(1.06);
  box-shadow: 0 12px 36px var(--brand-glow), 0 4px 8px rgba(59, 130, 246, 0.30);
}
.mic-fab:active:not(:disabled) { transform: scale(0.98); }
.mic-fab:focus-visible { outline: none; box-shadow: var(--shadow-fab), var(--ring-focus); }
.mic-fab:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: 0 4px 14px rgba(59, 130, 246, 0.15); }

.mic-fab-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--brand);
  opacity: 0;
  pointer-events: none;
}
.mic-fab.is-recording {
  background: var(--bad);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.35), 0 2px 6px rgba(239, 68, 68, 0.25);
}
.mic-fab.is-recording:hover { background: #dc2626; }
.mic-fab.is-recording .mic-fab-ring {
  animation: ring-pulse 1.4s ease-out infinite;
  border-color: var(--bad);
}
@keyframes ring-pulse {
  0%   { opacity: 0.8; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.5); }
}

.mic-fab-icon { display: inline-flex; align-items: center; justify-content: center; }
.mic-icon-stop { display: none; }
.mic-fab.is-recording .mic-icon-default { display: none; }
.mic-fab.is-recording .mic-icon-stop { display: inline-block; }

.mic-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
body.is-recording .mic-hint,
body.is-processing .mic-hint { visibility: hidden; }
.mic-fab:disabled ~ .mic-hint { color: var(--text-dim); }

/* =============================================================================
   MODALS (clause preview, custom clause)
   ============================================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modal-fade-in 160ms var(--ease-out);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: modal-card-in 200ms var(--ease-out);
}
@keyframes modal-card-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}
.modal-close:hover { color: var(--brand); background: var(--brand-faint); border-color: var(--brand-light); }
.modal-close:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.modal-title {
  margin: 0;
  padding: 24px 60px 8px 24px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.015em;
  color: var(--text);
}
.modal-body {
  padding: 6px 24px 24px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  overflow-y: auto;
  white-space: pre-wrap;
}

.modal-input,
.modal-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  display: block;
}
.modal-input::placeholder, .modal-textarea::placeholder { color: var(--text-dim); }
.modal-input:focus, .modal-textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring-focus);
  background: var(--surface);
}
.modal-textarea {
  margin-top: 10px;
  resize: vertical;
  min-height: 160px;
  white-space: pre-wrap;
}
.modal-input.is-error,
.modal-textarea.is-error {
  border-color: var(--bad);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.16);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.modal-btn {
  padding: 9px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.modal-btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.modal-btn-secondary { background: transparent; color: var(--text-muted); }
.modal-btn-secondary:hover { color: var(--text); }
.modal-btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
  font-family: var(--font-heading);
  font-weight: 600;
  box-shadow: 0 2px 8px var(--brand-glow);
}
.modal-btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  box-shadow: 0 4px 14px var(--brand-glow);
}
.modal-btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }

/* =============================================================================
   TOAST
   ============================================================================= */

.status-toast {
  position: fixed;
  bottom: 156px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 220ms var(--ease-out);
  /* Above any modal — settings & library are z-index: 110, app.js's
     dynamic clause modals at z-index: 100. Toast must sit above them so
     "couldn't upload" / "form added" feedback is visible while a modal
     is open (otherwise the backdrop dim swallows it). */
  z-index: 1000;
}
/* When a modal is open, also re-anchor the toast near the top of the
   viewport so it doesn't hide behind the centered modal-card. */
body.is-modal-open .status-toast {
  bottom: auto;
  top: 24px;
}
.status-toast.is-error { border-color: var(--bad); color: #b91c1c; }
.status-toast.is-good { border-color: var(--good); color: #047857; }
.status-toast.is-warn { border-color: var(--warn); color: #92400e; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 1024px) {
  .topbar { padding: 14px 20px; }
  .workspace { padding: 18px 16px 160px; }
  .workspace-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .fields-col {
    position: relative;
    top: auto;
    max-height: none;
  }
  .fields-body { max-height: 60vh; }
  .hero { padding: 32px 20px 96px; }
  .steps { gap: 6px; }
  .step { padding: 8px 12px; }
}

/* ---------- Settings modal (Phase 2 foundation) ----------
   Self-contained; intentionally NOT using `.modal-backdrop` because app.js's
   custom-clause modals do `document.querySelectorAll(".modal-backdrop")...remove()`
   on open and would wipe this element. Open/close via `.is-open` class on the
   modal itself — sidesteps any `[hidden]` vs class-rule specificity issue. */
.settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 110;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.settings-modal.is-open {
  display: flex;
  animation: modal-fade-in 160ms var(--ease-out);
}
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: modal-card-in 200ms var(--ease-out);
}
.settings-body {
  padding: 0 24px 16px;
  white-space: normal;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.settings-section {
  border: 1px solid var(--border);
  border-radius: var(--r-md, 10px);
  padding: 16px 18px 14px;
  background: var(--surface);
}
.settings-section-title {
  margin: 0 0 12px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.settings-section-sub {
  font-family: var(--font-body, inherit);
  font-weight: 500;
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 6px;
  letter-spacing: 0;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.settings-field-wide { grid-column: 1 / -1; }
.settings-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}
.settings-required { color: var(--bad); margin-left: 2px; }
.settings-photo-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.settings-photo-thumb {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--brand-faint);
  border: 1px solid var(--border);
  background-size: cover;
  background-position: center;
}
.settings-photo-thumb.has-image { background-color: var(--surface); }
.settings-photo-input {
  flex: 1 1 auto;
  font-size: 12px;
  color: var(--text-muted);
}
.settings-photo-clear {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}
.settings-photo-clear:hover { color: var(--bad); border-color: var(--bad); background: rgba(239, 68, 68, 0.06); }
.settings-footer {
  padding: 14px 24px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface);
  border-bottom-left-radius: var(--r-lg);
  border-bottom-right-radius: var(--r-lg);
}
.settings-cancel,
.settings-save {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.settings-cancel {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.settings-cancel:hover { color: var(--text); border-color: var(--text-muted); }
.settings-save {
  background: var(--brand);
  border: 1px solid var(--brand);
  color: #fff;
}
.settings-save:hover { background: var(--brand-strong, var(--brand)); }
.settings-save:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
body.is-modal-open { overflow: hidden; }

@media (max-width: 640px) {
  .settings-grid { grid-template-columns: 1fr; }
}

/* ---------- Template Library modal (Phase 2 step 2) ----------
   Reuses .settings-modal backdrop + .settings-card frame so library + settings
   share consistent visual language. The .library-modal modifier is purely a
   selector hook; styling lives on .library-* descendant rules. */
.library-card { max-width: 860px; }
.library-subtitle {
  margin: -2px 24px 14px;
  font-size: 13px;
  color: var(--text-muted);
}
.library-body { padding: 0 24px 24px; }
.library-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.library-card-row {
  border: 1px solid var(--border);
  border-radius: var(--r-md, 10px);
  padding: 14px 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.library-card-row.is-uploaded {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.04);
}
.library-card-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.library-card-title-wrap { min-width: 0; }
.library-card-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.library-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.library-card-status {
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.library-card-status.is-good { color: rgb(5, 122, 85); }
.library-card-status.is-pending { color: var(--text-muted); }
.library-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}
.library-status-dot.is-good { background: rgb(16, 185, 129); }
.library-status-dot.is-pending { background: rgb(217, 119, 6); }
.library-card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}
.library-btn {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.library-btn.is-primary {
  background: var(--brand);
  border: 1px solid var(--brand);
  color: #fff;
}
.library-btn.is-primary:hover { background: var(--brand-strong, var(--brand)); }
.library-btn.is-danger {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.library-btn.is-danger:hover { color: var(--bad); border-color: var(--bad); background: rgba(239, 68, 68, 0.06); }

@media (max-width: 720px) {
  .library-grid { grid-template-columns: 1fr; }
}

/* ---------- Home dashboard ----------
   Three sections: Quick Start packages, Individual Forms, My Deals.
   Centered with a wider 1280px cap so wide monitors don't strand the
   content against the left edge. Header/topbar stays full-width. */
.dashboard {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 24px 96px;
  display: flex;
  flex-direction: column;
  gap: 36px;
}
.dashboard-head { text-align: left; }
.dashboard-headline {
  margin: 0 0 6px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(28px, 3.6vw, 38px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
}
.dashboard-subhead {
  margin: 0;
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.5;
}
.dashboard-section { display: flex; flex-direction: column; gap: 12px; }
.dashboard-section-title {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.dashboard-section-tag {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 6px;
  letter-spacing: 0;
}
.dashboard-placeholder {
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: 18px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface-2);
}

/* Quick Start packages — wide tap-target cards */
.package-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.package-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), border-color var(--t-fast);
}
.package-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: var(--brand-light); }
.package-card:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.package-card.is-pending { background: var(--surface-2); }
.package-card.is-ready   { border-color: rgba(16, 185, 129, 0.32); }
.package-icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--brand-faint);
  font-size: 22px;
}
.package-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.package-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.package-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.package-status {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--brand-faint);
  color: var(--brand-hover);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.package-card.is-pending .package-status {
  background: rgba(217, 119, 6, 0.10);
  color: rgb(146, 64, 14);
}
.package-card.is-ready .package-status {
  background: rgba(16, 185, 129, 0.12);
  color: rgb(5, 122, 85);
}

/* Individual form buttons — compact pill-row layout */
.form-button-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.form-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: transform var(--t-fast) var(--ease-out), border-color var(--t-fast);
}
.form-button:hover { transform: translateY(-1px); border-color: var(--brand-light); }
.form-button:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.form-button.is-ready { border-color: rgba(16, 185, 129, 0.30); }
.form-button.is-pending { background: var(--surface-2); }
.form-button-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.form-button-status {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.form-button.is-ready .form-button-status { color: rgb(5, 122, 85); }
.form-button.is-pending .form-button-status { color: var(--text-muted); }

@media (max-width: 720px) {
  .package-grid { grid-template-columns: 1fr; }
  .form-button-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* =============================================================================
   Multi-pick selection (Phase 3A.3)
   ============================================================================= */

/* Both .package-card and .form-button need position: relative so the badge
   can absolute-position into their corner. .package-card already has
   position: static implied; declare both explicitly. */
.package-card,
.form-button { position: relative; }

.package-card.is-selected,
.form-button.is-selected {
  border-color: var(--brand);
  background: var(--brand-faint);
  box-shadow: 0 0 0 1px var(--brand) inset, var(--shadow-md);
}
.package-card.is-selected:hover,
.form-button.is-selected:hover {
  border-color: var(--brand-hover);
  box-shadow: 0 0 0 1px var(--brand-hover) inset, var(--shadow-md);
}

.selection-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: #fff;
  border-radius: 999px;
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  box-shadow: 0 2px 6px var(--brand-glow);
  pointer-events: none;
  animation: selection-badge-pop 180ms cubic-bezier(0.18, 1.2, 0.4, 1);
}
@keyframes selection-badge-pop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* Bottom padding on the dashboard so the last row of cards isn't hidden
   behind the floating bar when it's visible. ~80px = bar height + breathing. */
.dashboard.has-selection { padding-bottom: 88px; }

/* Floating bar — sits over the dashboard. Same surface treatment as other
   elevated panels (modal cards, tooltips). */
.selection-bar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translate(-50%, calc(100% + 24px));
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 16px;
  min-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill, 999px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.18), 0 0 0 4px var(--brand-faint);
  z-index: 900;
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1), opacity 220ms ease-out;
  opacity: 0;
}
.selection-bar.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.selection-bar-clear {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: var(--r-sm, 6px);
  cursor: pointer;
}
.selection-bar-clear:hover { background: var(--surface-2); color: var(--text); }

.selection-bar-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  margin: 0 4px;
}

.selection-bar-start {
  border: 0;
  background: var(--brand);
  color: #fff;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 8px 16px;
  border-radius: var(--r-pill, 999px);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), transform var(--t-fast);
}
.selection-bar-start:hover { background: var(--brand-hover); }
.selection-bar-start:active { transform: translateY(1px); }
.selection-bar-start:focus-visible { outline: none; box-shadow: var(--ring-focus); }

/* ---------- Topbar tooltips (Part 2D) ---------- */
.has-tooltip { position: relative; }
.has-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(-2px);
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  background: rgba(15, 23, 42, 0.92);
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease 0ms, transform 160ms ease 0ms;
  z-index: 1100;
}
.has-tooltip:hover::after,
.has-tooltip:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  transition-delay: 200ms;
}

/* ---------- Skeleton loaders (Part 2B) ---------- */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1.0; }
}
.skeleton-row {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2), var(--brand-faint), var(--surface-2));
  background-size: 200% 100%;
  margin: 8px 0;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.skeleton-row:nth-child(2) { width: 70%; }
.skeleton-row:nth-child(3) { width: 85%; }
.skeleton-empty {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 18px;
}
.skeleton-empty-text { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ---------- Clause Library (Phase 2 step 4) ---------- */
.clauses-card {
  max-width: 880px;
  max-height: 88vh;
  /* Card is the boundary — without overflow: hidden, an over-tall body
     visually escapes the card. Combined with .clauses-body's flex: 1 1 0 +
     min-height: 0 below, this turns the body into the proper scroll surface. */
  overflow: hidden;
}
.clauses-body {
  padding: 8px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  /* Flex-scroll fix v2 — `flex: 1 1 auto`, NOT `flex: 1 1 0`.
     The card has `max-height: 88vh` (a cap, not a set height) and the
     backdrop centers the card via `align-items: center`, so the card's
     height resolves from its CONTENT'S natural size. With `flex-basis: 0`
     the body contributed 0 to that natural size — the card collapsed to
     just the title (~50px), body got 0px, sections rendered into a 0-height
     scroll surface and were invisible (the v1 regression).
     With `flex-basis: auto` the body's basis is its content's natural size;
     card grows to fit (clamped at 88vh by max-height), body's `flex-shrink: 1`
     + `min-height: 0` + `overflow-y: auto` engages and scrolls when content
     exceeds the cap. Same scroll behavior, but a working layout. */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.clause-section {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  background: var(--surface);
}
.clause-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.clause-section-title {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.clause-section-count {
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 6px;
}
.clause-add-btn {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--brand);
  background: var(--brand-faint);
  color: var(--brand-hover);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.clause-add-btn:hover { background: var(--brand); color: #fff; }
.clause-list { display: flex; flex-direction: column; gap: 8px; }
.clause-list-empty { font-size: 12px; color: var(--text-muted); padding: 8px; }
.clause-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.clause-row.is-archived { opacity: 0.7; }
.clause-row-main { flex: 1 1 auto; min-width: 0; }
.clause-row-head { display: flex; align-items: center; gap: 8px; }
.clause-row-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.clause-row-preview {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.clause-badge {
  display: inline-flex;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--r-pill);
}
.clause-badge.is-default { background: var(--brand-faint); color: var(--brand-hover); }
.clause-badge.is-modified { background: rgba(245, 158, 11, 0.14); color: rgb(146, 64, 14); }
.clause-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.clause-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.clause-btn:hover { background: var(--brand-faint); color: var(--brand-hover); border-color: var(--brand-light); }
.clause-btn.is-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.clause-btn.is-primary:hover { background: var(--brand-hover); }
.clause-btn.is-danger:hover { background: rgba(239, 68, 68, 0.06); color: var(--bad); border-color: var(--bad); }
.clause-archived-section { padding: 0; }
.clause-archived-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-align: left;
}
.clause-archived-section.is-collapsed .clause-archived-list { display: none; }
.clause-archived-section.is-collapsed .clause-archived-caret { transform: rotate(-90deg); }
.clause-archived-caret { transition: transform var(--t-fast); }
.clause-archived-list { padding: 0 16px 16px; }
.clause-loading { padding: 12px 18px; }

/* Clause editor (nested modal). The nested modal needs higher z-index than
   the parent clauses-modal so it stacks correctly. */
.clause-edit-modal { z-index: 130; }
.clause-edit-card { max-width: 640px; max-height: 80vh; }
.clause-edit-body { padding: 0 24px 14px; }
.clause-edit-body-input {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  min-height: 220px;
  resize: vertical;
}
.clause-edit-helper {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
}
.clause-edit-helper code {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* ---------- Dark mode (Part 2C) ----------
   Light theme variables already live in :root. Dark theme overrides them
   when <html data-theme="dark"> is present. Brand blue stays consistent;
   surfaces/borders/text invert. No element-specific tweaks needed because
   every existing rule consumes these variables. */
:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111a2c;
  --surface-2: #0f1729;
  --border: #1e2a44;
  --border-strong: #2a3a5c;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --brand: #60a5fa;
  --brand-hover: #93c5fd;
  --brand-glow: rgba(96, 165, 250, 0.25);
  --brand-faint: rgba(96, 165, 250, 0.10);
  --brand-light: rgba(96, 165, 250, 0.18);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.40);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.50), 0 8px 24px rgba(0, 0, 0, 0.40);
  --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.40), 0 24px 60px rgba(0, 0, 0, 0.50);
}
:root[data-theme="dark"] .topbar { background: rgba(11, 18, 32, 0.85); }
:root[data-theme="dark"] .has-tooltip::after { background: rgba(226, 232, 240, 0.92); color: #0b1220; }
:root[data-theme="dark"] .clause-edit-body-input,
:root[data-theme="dark"] .modal-input,
:root[data-theme="dark"] .modal-textarea,
:root[data-theme="dark"] textarea { color: var(--text); background: var(--surface-2); }
:root[data-theme="dark"] .status-toast { color: var(--text); }

/* ---------- Settings: Appearance toggle (Part 2C) ---------- */
.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  cursor: pointer;
}
.settings-toggle-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.settings-toggle {
  /* Hidden checkbox — drives the slider via :checked sibling selector. */
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.settings-toggle-slider {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  transition: background var(--t-fast);
  flex-shrink: 0;
}
.settings-toggle-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff;
  transition: transform var(--t-fast);
  box-shadow: var(--shadow-sm);
}
.settings-toggle:checked ~ .settings-toggle-slider {
  background: var(--brand);
}
.settings-toggle:checked ~ .settings-toggle-slider::after {
  transform: translateX(18px);
}

/* ---------- Clause Library: accordion + tight rows (post-step-4 fixes) ----------
   Overrides earlier .clause-section / .clause-row rules (defined later in the
   stylesheet so they win on equal specificity). The library is now a vertical
   stack of accordion items: each header toggles its body via .is-collapsed. */
.clause-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0;
  overflow: hidden;
  /* `.clauses-body` is `display: flex; flex-direction: column`, so sections
     are flex items with default `flex-shrink: 1`. With body's height capped
     by the card's `max-height: 88vh`, flex would otherwise shrink each
     section proportionally to fit, then the section's own `overflow: hidden`
     clips the inner list — leaving only the first ~5 rows visible.
     `flex-shrink: 0` keeps each section at its content's natural size, so
     total body content exceeds the cap and body's `overflow-y: auto` engages.
     This is THE scroll fix — earlier attempts only touched the body level
     and missed that the children were being squeezed before overflow could
     happen. Diagnosed via headless-browser computed-style dump: section was
     rendering at h=479 with scrollHeight=1497 = clipped flex-shrink. */
  flex-shrink: 0;
}
.clause-section + .clause-section { margin-top: 8px; }
/* Same flex-shrink fix for the Hidden Clauses section at the bottom of the
   accordion — it's a sibling of the three accordion sections. */
.clause-archived-section { flex-shrink: 0; }

.clause-section-head {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 0;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background var(--t-fast);
}
.clause-section-head:hover { background: var(--surface-2); }
.clause-section-caret {
  flex: 0 0 auto;
  color: var(--text-muted);
  transition: transform var(--t-fast);
}
.clause-section.is-collapsed .clause-section-caret { transform: rotate(-90deg); }
.clause-section-title {
  flex: 0 0 auto;
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.clause-section-spacer { flex: 1 1 auto; }
.clause-section .clause-add-btn {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--brand-light);
  background: var(--brand-faint);
  color: var(--brand-hover);
}
.clause-section .clause-add-btn:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Body: smooth open/close via grid-template-rows transition (Option A from
   the scroll-fix prompt). 1fr expanded → 0fr collapsed. NO max-height clamp,
   so any number of rows fits. The .clauses-body modal container is the
   scroll surface (`max-height: 88vh; overflow-y: auto`). */
.clause-section-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 220ms ease-in-out, opacity 160ms ease-in-out;
  opacity: 1;
}
.clause-section.is-collapsed .clause-section-body {
  grid-template-rows: 0fr;
  opacity: 0;
}
.clause-section-body > .clause-list {
  min-height: 0;     /* required so the 0fr track actually clips */
  overflow: hidden;
  border-top: 1px solid var(--border);
  padding: 4px 8px 8px;
  display: flex;
  flex-direction: column;
}
.clause-section.is-collapsed .clause-section-body > .clause-list {
  border-top-color: transparent;
}

/* Tight row: ~64-80px tall. Title + badge + actions inline; preview below
   single-line ellipsized. Border-bottom separator instead of full card. */
.clause-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 4px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  transition: background var(--t-fast);
}
.clause-row:last-child { border-bottom: 0; }
.clause-row:hover { background: var(--surface-2); }
.clause-row.is-archived { opacity: 0.7; }

.clause-row-main {
  /* Children of the row's main column flow vertically: title row then preview. */
  grid-column: 1 / 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.clause-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.clause-row-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.clause-row-preview {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0;
}
.clause-row-actions {
  grid-column: 2 / 3;
  grid-row: 1 / 3;       /* span both rows so it vertically centers */
  align-self: center;
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.clause-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.clause-btn:hover { background: var(--brand-faint); color: var(--brand-hover); }
.clause-btn.is-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.clause-btn.is-primary:hover { background: var(--brand-hover); }
.clause-btn.is-danger:hover { background: rgba(239, 68, 68, 0.08); color: var(--bad); }

/* Hidden Clauses footer remains independent of the accordion group; it's
   rendered without `data-accordion` so toggleSection / openSection ignore it. */
.clause-archived-section { margin-top: 12px; }

/* ---------- Deals dashboard list (Phase 2 step 5) ---------- */
.deals-list { display: flex; flex-direction: column; gap: 8px; }
.deals-empty {
  padding: 18px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface-2);
}
.deals-loading { padding: 6px 2px; }
.deal-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 4px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.deal-row:hover { background: var(--surface-2); border-color: var(--brand-light); }
.deal-row-main { grid-column: 1 / 2; min-width: 0; }
.deal-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.deal-row-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.deal-row-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.deal-row-sep { color: var(--text-dim); }
.deal-row-actions {
  grid-column: 2 / 3;
  grid-row: 1 / 3;
  align-self: center;
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.deal-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.deal-btn:hover { background: var(--brand-faint); color: var(--brand-hover); border-color: var(--brand-light); }
.deal-btn.is-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.deal-btn.is-primary:hover { background: var(--brand-hover); }
.deal-btn.is-danger:hover { background: rgba(239, 68, 68, 0.06); color: var(--bad); border-color: var(--bad); }

.deal-badge {
  display: inline-flex;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--r-pill);
}
.deal-badge.is-warn { background: rgba(245, 158, 11, 0.14); color: rgb(146, 64, 14); }
.deal-badge.is-good { background: rgba(16, 185, 129, 0.12); color: rgb(5, 122, 85); }
.deal-badge.is-info { background: var(--brand-faint); color: var(--brand-hover); }

/* ---------- Fill-view deal controls ---------- */
.deal-title-row {
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.deal-title-label { font-weight: 600; }
.deal-title-text {
  font-weight: 600;
  color: var(--text);
}
.deal-controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 0;
}
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.btn-secondary:hover { background: var(--brand-faint); color: var(--brand-hover); border-color: var(--brand-light); }
.btn-secondary:disabled { opacity: 0.55; cursor: not-allowed; }
.deal-status-select {
  font-family: inherit;
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.deal-status-select:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- PDF generation skeleton overlay (Polish pass FIX 2B) ---------- */
.pdf-generate-skeleton {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 40px 24px;
  gap: 16px;
  background: rgba(244, 247, 255, 0.85);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index: 5;
  pointer-events: none;
}
.pdf-generate-skeleton-page {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-md);
}
.pdf-generate-skeleton-text {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.preview-body { position: relative; }
:root[data-theme="dark"] .pdf-generate-skeleton {
  background: rgba(11, 18, 32, 0.85);
}

/* ---------- Forms Library skeleton cards (Polish pass FIX 2C) ---------- */
.library-card-skeleton {
  pointer-events: none;
  background: var(--surface);
}
.library-card-skeleton .library-card-head { width: 100%; }
.library-card-skeleton .skeleton-row { background: linear-gradient(90deg, var(--surface-2), var(--brand-faint), var(--surface-2)); }

/* ----- Attachments (Schedule B / addenda) ----- */

/* Three-zone attachment modal — header (.modal-title) / body
   (.attachments-body) / footer (.attachments-footer). Mirrors the Settings
   modal's pattern (padding 24px sides, 1px border-top above the footer,
   right-aligned action buttons) so attachment modals feel like part of the
   same family. */
.attachments-card {
  max-width: 560px;
  width: min(90vw, 560px);
}
.attachments-body {
  padding: 0 24px 16px;
  white-space: normal;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.attachments-footer {
  padding: 14px 24px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface);
  border-bottom-left-radius: var(--r-lg);
  border-bottom-right-radius: var(--r-lg);
}
.attachments-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}
.attachments-helper {
  margin: 0 0 4px;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.5;
}
/* Expanded-stage block: helper + dropzone + list, vertically stacked
   inside the body's flex column with its own tighter rhythm. */
.attachments-stage-expanded {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.attachments-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 28px 16px;
  border: 1.5px dashed var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
  text-align: center;
}
.attachments-dropzone.is-hover, .attachments-dropzone:hover {
  border-color: var(--brand);
  background: var(--surface-2);
}
.attachments-dropzone-text {
  font-size: 13.5px;
  color: var(--text);
  font-weight: 500;
}
.attachments-dropzone-click { color: var(--brand); text-decoration: underline; }
.attachments-dropzone-hint {
  font-size: 11.5px;
  color: var(--text-dim);
}
.attachments-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.attachments-row {
  display: grid;
  grid-template-columns: 24px 1fr 30px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.attachments-row-handle {
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
}
.attachments-row-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.attachments-row-label {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  padding: 4px 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  width: 100%;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.attachments-row-label:hover { border-color: var(--border); }
.attachments-row-label:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--surface-2);
  box-shadow: var(--ring-focus);
}
.attachments-row-file {
  font-size: 11px;
  color: var(--text-dim);
  padding-left: 6px;
}
.attachments-row-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--t-fast);
}
.attachments-row-remove:hover {
  color: #f87171;
  border-color: #f87171;
}

/* In-fill header attach button — shows count badge when attachments > 0. */
.attach-doc-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.attach-doc-btn [data-attach-count] {
  font-size: 13px;
}

/* Paperclip badge in the My Deals list. Sits next to the deal title. */
.deal-attach-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--surface-2);
}

/* =============================================================================
   Phase 3A.3 — Pricing page + Subscription section
   ============================================================================= */

.pricing-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.pricing-hero { text-align: center; margin-bottom: 32px; }
.pricing-headline {
  font-family: var(--font-heading);
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  color: var(--text);
}
.pricing-subhead {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}
@media (max-width: 880px) { .pricing-grid { grid-template-columns: 1fr; } }

.pricing-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 28px 22px 22px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-fast) var(--ease-out), border-color var(--t-fast), box-shadow var(--t-fast);
}
.pricing-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.pricing-card.is-recommended {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand) inset, var(--shadow-md);
}
.pricing-card-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand);
  color: #fff;
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 999px;
  box-shadow: 0 2px 6px var(--brand-glow);
}
.pricing-card-head { margin-bottom: 14px; }
.pricing-card-name {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.pricing-card-price {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.pricing-card-price .amount {
  font-family: var(--font-heading);
  font-size: 36px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.pricing-card-price .cadence {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
.pricing-card-quota {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
  margin: 0 0 14px;
}
.pricing-card-features {
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
}
.pricing-card-features li {
  position: relative;
  padding-left: 22px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
}
.pricing-card-features li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--brand-faint);
  background-image: linear-gradient(45deg, transparent 50%, var(--brand) 50%);
  background-size: 14px 14px;
  background-position: -7px 0;
  background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 25%, transparent);
}
.pricing-card-cta {
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-radius: var(--r-sm, 8px);
  background: var(--brand);
  color: #fff;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out);
}
.pricing-card-cta:hover { background: var(--brand-hover); }
.pricing-card-cta:disabled { opacity: 0.6; cursor: wait; }
.pricing-card-cta:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.pricing-card:not(.is-recommended) .pricing-card-cta {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.pricing-card:not(.is-recommended) .pricing-card-cta:hover {
  background: var(--brand-faint);
  border-color: var(--brand);
}

.pricing-footnote {
  margin-top: 32px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
.pricing-back {
  color: var(--brand);
  text-decoration: none;
  margin-left: 12px;
}
.pricing-back:hover { text-decoration: underline; }

/* Subscription section inside Settings modal */
.settings-subscription-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}
.settings-subscription-info { display: flex; flex-direction: column; gap: 2px; }
.settings-subscription-tier {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.settings-subscription-usage {
  font-size: 12px;
  color: var(--text-muted);
}
.settings-subscription-cta {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast);
}
.settings-subscription-cta:hover { background: var(--brand-faint); border-color: var(--brand); color: var(--brand-hover); }
.settings-subscription-cta:disabled { opacity: 0.6; cursor: wait; }

/* =============================================================================
   Phase 3A.4 — User dropdown (email + dividers) + Account page
   ============================================================================= */

/* Dropdown gets a small email header + dividers between groups */
.user-chip-menu {
  /* Override the 3A.1 default width so the email fits comfortably. */
  min-width: 240px;
}
.user-chip-menu-email {
  padding: 6px 10px 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.user-chip-menu-divider {
  height: 1px;
  margin: 4px -6px;
  background: var(--border);
}
/* Make the anchor element behave the same as the button menu items. */
.user-chip-menu a.user-chip-menu-item {
  text-decoration: none;
  color: var(--text);
}

/* =============================================================================
   Account page (/account)
   ============================================================================= */

.account-shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 36px 24px 80px;
}
.account-loading {
  text-align: center;
  color: var(--text-muted);
  padding: 80px 0;
  font-size: 14px;
}
.account-hero { margin-bottom: 32px; }
.account-headline {
  font-family: var(--font-heading);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 6px;
}
.account-subhead {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

.account-section { margin-bottom: 32px; }
.account-section-title {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.account-plan-card {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto auto;
  grid-template-areas:
    "name  price"
    "quota price"
    "renew renew";
  gap: 4px 24px;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.account-plan-card-name {
  grid-area: name;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 22px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.account-plan-card-price {
  grid-area: price;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 22px;
  color: var(--brand);
  letter-spacing: -0.01em;
  align-self: center;
  text-align: right;
}
.account-plan-card-quota {
  grid-area: quota;
  font-size: 13px;
  color: var(--text-muted);
}
.account-plan-card-renews {
  grid-area: renew;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.account-usage-card {
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.account-usage-headline {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
  color: var(--text);
}
.account-usage-headline.is-paid { color: var(--text); }
.account-usage-headline.is-available { color: var(--brand); }
.account-usage-headline.is-exhausted { color: var(--bad, #ef4444); }
.account-usage-headline.is-unlimited { color: var(--brand); }
.account-usage-bar {
  width: 100%;
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}
.account-usage-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--brand);
  border-radius: 4px;
  transition: width 320ms cubic-bezier(0.16, 1, 0.3, 1);
}
.account-usage-bar-fill.is-full { background: var(--bad, #ef4444); }
.account-usage-bar-fill.has-overage { background: var(--warn, #f59e0b); }
.account-usage-foot {
  font-size: 12px;
  color: var(--text-muted);
}

.account-tier-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 720px) { .account-tier-grid { grid-template-columns: 1fr; } }

.account-tier-card {
  display: flex;
  flex-direction: column;
  padding: 20px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-fast) var(--ease-out), border-color var(--t-fast);
}
.account-tier-card:hover { transform: translateY(-1px); border-color: var(--brand-light); }
.account-tier-card.is-current {
  border-color: var(--brand);
  background: var(--brand-faint);
  box-shadow: 0 0 0 1px var(--brand) inset;
}
.account-tier-card.is-current:hover { transform: none; }
.account-tier-card-head { margin-bottom: 8px; }
.account-tier-card-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  margin: 0 0 2px;
  letter-spacing: -0.01em;
}
.account-tier-card-price {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 2px;
}
.account-tier-card-price .amount {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
}
.account-tier-card-price .cadence {
  font-size: 12px;
  color: var(--text-muted);
}
.account-tier-card-quota {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  margin: 0 0 16px;
}
.account-tier-cta {
  margin-top: auto;
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast), color var(--t-fast);
}
.account-tier-cta:hover { background: var(--brand-faint); border-color: var(--brand); color: var(--brand-hover); }
.account-tier-cta:disabled { opacity: 0.6; cursor: wait; }
.account-tier-cta.is-upgrade {
  background: var(--brand);
  color: #fff;
  border-color: transparent;
}
.account-tier-cta.is-upgrade:hover { background: var(--brand-hover); color: #fff; border-color: transparent; }
.account-tier-cta.is-downgrade { color: var(--text-muted); }
.account-tier-cta.is-downgrade:hover { color: var(--bad, #ef4444); border-color: var(--bad, #ef4444); background: rgba(239, 68, 68, 0.06); }
.account-tier-current-badge {
  margin-top: auto;
  display: inline-block;
  padding: 9px 14px;
  text-align: center;
  background: transparent;
  border: 1px solid var(--brand);
  border-radius: 8px;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
}
.account-tier-foot {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.account-billing-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.account-billing-info { display: flex; flex-direction: column; gap: 2px; }
.account-billing-label { font-size: 13px; color: var(--text-muted); }
.account-billing-cta {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast), color var(--t-fast);
}
.account-billing-cta:hover { background: var(--brand-faint); border-color: var(--brand); color: var(--brand-hover); }
.account-billing-cta:disabled { opacity: 0.6; cursor: wait; }

/* =============================================================================
   Pricing subscriber banner
   ============================================================================= */

.pricing-subscriber-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: var(--brand-faint);
  border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
  border-radius: var(--r-md);
}
.pricing-subscriber-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.pricing-subscriber-link {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand);
  text-decoration: none;
}
.pricing-subscriber-link:hover { color: var(--brand-hover); text-decoration: underline; }

/* =============================================================================
   Phase 3A.5 — Legal pages (/terms, /privacy)
   ============================================================================= */

.legal-shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.legal-hero { margin-bottom: 28px; }
.legal-headline {
  font-family: var(--font-heading);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 6px;
}
.legal-effective {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* Prose body — tuned for long-form readability. Inherits site fonts/colors. */
.legal-prose {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: 28px 32px;
  color: var(--text);
}
.legal-prose h2 {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  margin: 28px 0 10px;
}
.legal-prose h2:first-child { margin-top: 0; }
.legal-prose h3 {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 18px 0 8px;
}
.legal-prose p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  margin: 0 0 12px;
}
.legal-prose ul {
  margin: 0 0 12px;
  padding-left: 22px;
}
.legal-prose li {
  font-size: 14px;
  line-height: 1.65;
  margin-bottom: 4px;
}
.legal-prose a {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.legal-prose a:hover { color: var(--brand-hover); }
.legal-prose strong { font-weight: 600; }

/* Shared site footer (used on legal pages today; future pages can adopt). */
.legal-footer {
  border-top: 1px solid var(--border);
  margin-top: 0;
  padding: 24px 24px;
  background: transparent;
}
.legal-footer-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.legal-footer-links { display: inline-flex; align-items: center; gap: 8px; }
.legal-footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}
.legal-footer-links a:hover { color: var(--text); text-decoration: underline; }
.legal-footer-sep { color: var(--text-dim); }
.legal-footer-copy { margin: 0; color: var(--text-dim); }
