/* ===== Base tokens ===== */
:root {
  --doc-serif: 'Merriweather', 'Noto Sans SC', 'Noto Sans JP', 'Noto Sans Devanagari', Georgia, 'Times New Roman', serif;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  width: 100%;
}

body {
  font-feature-settings: "cv11", "ss01";
  overflow-x: hidden;
  width: 100%;
}

/* ===== Ad placeholders ===== */
.ad-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1.5px dashed rgb(148 163 184 / 0.5);
  border-radius: 0.75rem;
  background: repeating-linear-gradient(
    45deg,
    rgb(148 163 184 / 0.06),
    rgb(148 163 184 / 0.06) 10px,
    rgb(148 163 184 / 0.12) 10px,
    rgb(148 163 184 / 0.12) 20px
  );
  color: rgb(100 116 139);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  min-height: 90px;
  margin: 0 auto;
}
.dark .ad-placeholder {
  color: rgb(148 163 184);
  border-color: rgb(71 85 105 / 0.6);
}
.ad-native {
  min-height: 100px;
  width: 100%;
}

/* Party A's fieldset expands to fill the row when Party B is hidden
   (Privacy Policy has no counterparty). */
.party-fieldset-expand {
  grid-column: 1 / -1;
}

/* ===== Template selector cards ===== */
.template-card {
  position: relative;
  text-align: left;
  padding: 1rem;
  border-radius: 1rem;
  border: 1.5px solid rgb(226 232 240);
  background: white;
  transition: all 0.15s ease;
}
.dark .template-card {
  background: rgb(15 23 42);
  border-color: rgb(30 41 59);
}
.template-card:hover {
  border-color: rgb(147 197 253);
  transform: translateY(-1px);
}
.template-card.active {
  border-color: rgb(59 130 246);
  background: rgb(59 130 246 / 0.1);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.15);
}
.dark .template-card.active {
  background: rgb(59 130 246 / 0.15);
  border-color: rgb(59 130 246);
}
/* Small "selected" badge, only visible on the active card — a second,
   at-a-glance cue beyond the border/background so the active state
   reads clearly even at a glance or in a screenshot. */
.template-card-check {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 9999px;
  background: rgb(59 130 246);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.template-card.active .template-card-check {
  opacity: 1;
  transform: scale(1);
}

/* ===== Template selector: mobile compact tab bar ===== */
.template-tabs {
  display: flex;
  gap: 0.5rem;
}
/* Below 640px, 4 items squeezed into one flex row leaves each tab too
   narrow for its icon+label (and risks the "Activo" badge overflowing
   its own tab) — a balanced 2x2 grid gives each one real room instead. */
@media (max-width: 639px) {
  .template-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  .template-tab {
    flex-direction: row;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 0.5rem;
    font-size: 0.78rem;
  }
  .template-tab-icon {
    width: 1.05rem;
    height: 1.05rem;
  }
}
.template-tab {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.6rem 0.25rem;
  border-radius: 0.75rem;
  border: 1.5px solid rgb(226 232 240);
  background: white;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgb(71 85 105);
  transition: all 0.2s ease-out;
}
.dark .template-tab {
  background: rgb(15 23 42 / 0.7);
  border-color: rgb(30 41 59);
  color: rgb(148 163 184);
}
.template-tab:hover {
  border-color: rgb(59 130 246 / 0.5);
  box-shadow: 0 8px 20px -8px rgb(59 130 246 / 0.3);
  transform: translateY(-2px);
}
.template-tab-icon {
  width: 1.2rem;
  height: 1.2rem;
  flex-shrink: 0;
}
.template-tab.active {
  border-color: rgb(59 130 246);
  background: rgb(59 130 246 / 0.1);
  color: rgb(37 99 235);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.15);
}
.dark .template-tab.active {
  background: rgb(59 130 246 / 0.15);
  border-color: rgb(59 130 246);
  color: rgb(96 165 250);
}
.template-tab-active-badge {
  display: none;
  position: absolute;
  top: -0.5rem;
  right: 0.4rem;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.1rem 0.4rem;
  border-radius: 9999px;
  background: linear-gradient(to right, rgb(37 99 235), rgb(79 70 229));
  color: white;
  box-shadow: 0 2px 6px -1px rgb(59 130 246 / 0.5);
  white-space: nowrap;
  max-width: calc(100% - 0.8rem);
  overflow: hidden;
  text-overflow: ellipsis;
}
.template-tab.active .template-tab-active-badge {
  display: inline-block;
}
/* From sm up, the tab bar is the only template selector (no more card
   grid) — lay it out as a slim horizontal row (icon beside label, not
   stacked) with a bit more breathing room per tab. */
@media (min-width: 640px) {
  .template-tab {
    flex-direction: row;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 0.5rem;
    font-size: 0.8rem;
  }
  .template-tab-icon {
    width: 1.05rem;
    height: 1.05rem;
  }
}

/* ===== Step wizard (ultra-compact) ===== */
.step-dot {
  height: 1.45rem;
  width: 1.45rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgb(226 232 240);
  color: rgb(100 116 139);
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.dark .step-dot {
  background: rgb(30 41 59);
  color: rgb(148 163 184);
}
.step-dot.active {
  background: rgb(37 99 235);
  color: white;
}
.step-dot.done {
  background: rgb(16 185 129);
  color: white;
}
.step-line {
  flex: 1;
  height: 2px;
  background: rgb(226 232 240);
  min-width: 1rem;
}
.dark .step-line {
  background: rgb(30 41 59);
}

.form-step.hidden {
  display: none;
}

/* ===== Form fields ===== */
.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: rgb(71 85 105);
  margin-bottom: 0.25rem;
}
.dark .field-label {
  color: rgb(148 163 184);
}
.field-input {
  width: 100%;
  border-radius: 0.6rem;
  border: 1.5px solid rgb(226 232 240);
  background: rgb(248 250 252);
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  color: rgb(15 23 42);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dark .field-input {
  background: rgb(2 6 23 / 0.4);
  border-color: rgb(30 41 59);
  color: rgb(241 245 249);
}
.field-input:focus {
  outline: none;
  border-color: rgb(59 130 246);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.15);
}

/* Bigger thumb-friendly tap targets on mobile (also avoids iOS input auto-zoom) */
@media (max-width: 640px) {
  .field-input {
    padding: 0.75rem 0.9rem;
    font-size: 1rem;
  }
  .btn-primary, .btn-secondary, .btn-ghost {
    padding: 0.7rem 1.1rem;
    font-size: 0.9rem;
  }
}

/* ===== Buttons ===== */
.btn-primary, .btn-secondary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: 0.6rem;
  transition: all 0.2s ease-out;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(to right, rgb(37 99 235), rgb(79 70 229));
  color: white;
  box-shadow: 0 8px 20px -8px rgb(59 130 246 / 0.5);
  border: 1px solid rgb(255 255 255 / 0.1);
}
.btn-primary:hover {
  background: linear-gradient(to right, rgb(59 130 246), rgb(99 102 241));
  box-shadow: 0 10px 25px -6px rgb(59 130 246 / 0.55);
  transform: translateY(-1px);
}
.btn-secondary {
  background: rgb(226 232 240);
  color: rgb(30 41 59);
}
.dark .btn-secondary {
  background: rgb(30 41 59 / 0.8);
  color: rgb(226 232 240);
  border: 1px solid rgb(51 65 85 / 0.6);
}
.btn-secondary:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
}
.dark .btn-secondary:hover {
  border-color: rgb(59 130 246 / 0.4);
}
.btn-ghost {
  background: transparent;
  color: rgb(71 85 105);
  border: 1.5px solid rgb(226 232 240);
}
.dark .btn-ghost {
  color: rgb(148 163 184);
  border-color: rgb(30 41 59);
}
.btn-ghost:hover {
  background: rgb(248 250 252);
  border-color: rgb(147 197 253);
}
.dark .btn-ghost:hover {
  background: rgb(30 41 59 / 0.5);
  border-color: rgb(59 130 246 / 0.4);
}
.btn-ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-primary:disabled, .btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===== Language selector ===== */
.lang-select {
  appearance: none;
  background: rgb(241 245 249) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.6rem center/0.9rem;
  border: 1.5px solid rgb(226 232 240);
  border-radius: 9999px;
  padding: 0.4rem 2rem 0.4rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: rgb(30 41 59);
  cursor: pointer;
}
.dark .lang-select {
  background-color: rgb(30 41 59);
  border-color: rgb(51 65 85);
  color: rgb(226 232 240);
}
.lang-select-sm {
  border-radius: 0.5rem;
  padding: 0.3rem 1.6rem 0.3rem 0.6rem;
  font-size: 0.75rem;
  width: 100%;
}
.lang-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.lang-select-icon {
  position: absolute;
  left: 0.65rem;
  width: 0.8rem;
  height: 0.8rem;
  color: rgb(100 116 139);
  pointer-events: none;
}
.dark .lang-select-icon {
  color: rgb(148 163 184);
}
.lang-select-wrap .lang-select {
  padding-left: 1.75rem;
}
/* Compact header navbar on narrow phones: the language option text
   ("ES · Español", "RU · Русский"...) can be longer than the available
   header width once the logo + donate + theme buttons are also on the
   same row — cap and truncate it instead of letting it force the whole
   header wider than the viewport. */
@media (max-width: 480px) {
  .lang-select-wrap .lang-select {
    max-width: 4.6rem;
    padding-right: 1.2rem;
    font-size: 0.68rem;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    background-position: right 0.4rem center;
    background-size: 0.75rem;
  }
  .donate-btn-nav,
  #theme-toggle {
    flex-shrink: 0;
  }
}

/* ===== Bilingual (dual-language) toolbar ===== */
.bilingual-toolbar {
  border: 1.5px solid rgb(226 232 240);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: rgb(248 250 252);
}
.dark .bilingual-toolbar {
  border-color: rgb(30 41 59);
  background: rgb(2 6 23 / 0.3);
}
.bilingual-switch-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: rgb(30 41 59);
  cursor: pointer;
  user-select: none;
}
.dark .bilingual-switch-label {
  color: rgb(226 232 240);
}
.bilingual-switch-label input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.bilingual-switch {
  position: relative;
  flex-shrink: 0;
  width: 2.4rem;
  height: 1.35rem;
  border-radius: 9999px;
  background: rgb(203 213 225);
  transition: background 0.2s ease;
}
.dark .bilingual-switch {
  background: rgb(51 65 85);
}
.bilingual-switch::before {
  content: '';
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 9999px;
  background: white;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.2);
}
.bilingual-switch-label input:checked + .bilingual-switch {
  background: rgb(37 99 235);
}
.bilingual-switch-label input:checked + .bilingual-switch::before {
  transform: translateX(1.05rem);
}
.bilingual-lang-picker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgb(226 232 240);
}
.dark .bilingual-lang-picker {
  border-color: rgb(30 41 59);
}
.bilingual-lang-picker.hidden {
  display: none;
}
.bilingual-lang-picker-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: rgb(100 116 139);
}
.bilingual-primary-readout {
  font-size: 0.78rem;
  font-weight: 600;
  color: rgb(30 41 59);
  background: rgb(226 232 240);
  border-radius: 0.5rem;
  padding: 0.3rem 0.6rem;
}
.dark .bilingual-primary-readout {
  color: rgb(226 232 240);
  background: rgb(51 65 85);
}
#bilingual-secondary-select {
  width: auto;
  min-width: 8rem;
}

/* ===== Document / PDF preview — editorial / corporate redesign ===== */
.doc-page {
  font-family: var(--doc-serif);
  background: #fffefc;
  color: #1c1c1c;
  padding: 2.4rem 2.2rem;
  font-size: 0.82rem;
  line-height: 1.6;
  min-height: 400px;
}
.dark .doc-page {
  background: #fdfdfb;
  color: #1c1c1c;
}
.doc-page p {
  margin-bottom: 1rem;
  text-align: justify;
}
.doc-page .placeholder-text {
  color: #b45309;
  font-style: italic;
}

/* --- Letterhead --- */
.doc-page .doc-letterhead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
}
.doc-page .doc-letterhead-logo {
  flex-shrink: 0;
}
.doc-page .doc-logo-placeholder {
  width: 1px;
  height: 1px;
}
.doc-page .doc-letterhead-meta {
  text-align: right;
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
}
.doc-page .doc-letterhead-title {
  font-family: var(--doc-serif);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #111827;
  margin-bottom: 0.5rem;
  line-height: 1.35;
}
.doc-page .doc-letterhead-ref,
.doc-page .doc-letterhead-date {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}
.doc-page .doc-letterhead-ref {
  margin-bottom: 0.2rem;
}
.doc-page .doc-letterhead-divider {
  border-bottom: 2px solid #e2e8f0;
  margin: 1.1rem 0 1.6rem;
}

/* --- Party identification cards --- */
.doc-page .doc-parties-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  margin-bottom: 1.3rem;
}
.doc-page .party-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.9rem 1rem;
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  /* A grid item's default min-width is auto (its content's min-content
     size), not 0 — an unbroken long token (a very long ID/tax number, a
     name with no spaces) would otherwise refuse to shrink to the 50%
     track and push this whole card off the page in the PDF export.
     min-width:0 here lets it shrink; overflow-wrap on the text below
     makes it actually wrap instead of just clipping. */
  min-width: 0;
  overflow-wrap: break-word;
}
.doc-page .party-card-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #475569;
  margin-bottom: 0.35rem;
}
.doc-page .party-card-name {
  font-family: var(--doc-serif);
  font-size: 0.92rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.45rem;
}
.doc-page .party-card-row {
  font-size: 0.7rem;
  color: #334155;
  margin-bottom: 0.15rem;
  line-height: 1.45;
}
.doc-page .party-card-row span {
  font-weight: 600;
  color: #64748b;
}

/* --- Bilingual (dual-language) side-by-side table ---
   A real <table> (not CSS grid) is used deliberately: html2canvas does
   not reliably lock a CSS grid row's height to its tallest cell, so a
   shorter-language column would visually flow into the next clause
   while the taller column was still finishing the current one once
   captured/paginated. A <table>'s <tr> guarantees both cells share one
   row height in every rendering engine, and 'tr' is already in the
   html2pdf pagebreak avoid list, so each row also stays on one page. */
.doc-page .bilingual-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin-bottom: 0.5rem;
}
.doc-page .bilingual-table td.bilingual-cell {
  width: 50%;
  vertical-align: top;
  padding: 0.4rem 0 0.4rem 0.9rem;
}
.doc-page .bilingual-table td.bilingual-cell:first-child {
  border-right: 1px solid #f1f5f9;
  padding-left: 0;
  padding-right: 0.9rem;
}
.doc-page .bilingual-table .bilingual-lang-header {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #2563eb;
  padding-bottom: 0.4rem !important;
  border-bottom: 2px solid #dbeafe;
}
@media (max-width: 640px) {
  .doc-page .bilingual-table,
  .doc-page .bilingual-table tbody,
  .doc-page .bilingual-table tr,
  .doc-page .bilingual-table td.bilingual-cell {
    display: block;
    width: 100%;
  }
  .doc-page .bilingual-table td.bilingual-cell:first-child {
    border-right: none;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 0.5rem;
  }
  .doc-page .bilingual-table td.bilingual-cell:last-child {
    padding: 0.4rem 0;
  }
}

/* --- Clauses --- */
.doc-page .clause-block {
  border-left: 3px solid #e2e8f0;
  padding-left: 1rem;
  margin: 1.1rem 0;
  page-break-inside: avoid;
  break-inside: avoid;
}
.doc-page .clause-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.45rem;
  page-break-after: avoid;
  break-after: avoid;
}
.doc-page .clause-num {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0.35rem;
  background: #f1f5f9;
  color: #475569;
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.doc-page h2.clause-title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0;
}

/* --- Signature cards --- */
.doc-page .sign-block {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  margin-top: 1.6rem;
  page-break-inside: avoid;
  break-inside: avoid;
}
.doc-page .sign-card {
  border: 1.5px solid #e2e8f0;
  border-radius: 0.6rem;
  padding: 0.95rem;
  text-align: center;
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  page-break-inside: avoid;
  break-inside: avoid;
  /* Same fix as .party-card: a grid item's default min-width is auto
     (sized to its content), so a long unbroken value in a sign-field
     (e.g. a long tax/ID number echoed from the form) would refuse to
     shrink to the 50% track and get clipped by the preview's own
     overflow:hidden, or push the card off the page in the PDF export. */
  min-width: 0;
  overflow-wrap: break-word;
}
.doc-page .sign-card-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #475569;
  margin-bottom: 0.7rem;
}
.doc-page .sign-area {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}
.doc-page .sign-area-empty {
  width: 100%;
  height: 50px;
  border: 1px dashed #cbd5e1;
  border-radius: 0.35rem;
}
.doc-page .sign-img {
  display: block;
  max-height: 55px;
  max-width: 90%;
  margin: 0 auto;
  object-fit: contain;
}
.doc-page .sign-line {
  border-top: 1.5px solid #334155;
  margin-bottom: 0.65rem;
}
.doc-page .sign-field {
  font-size: 0.7rem;
  color: #334155;
  text-align: left;
  margin-bottom: 0.25rem;
  line-height: 1.45;
}
.doc-page .sign-field strong {
  color: #111827;
}

/* Privacy Policy has no counterparty: a single, full-width party/sign
   card instead of the two-column layout every other document type uses. */
.doc-page .doc-parties-grid.single,
.doc-page .sign-block.single {
  grid-template-columns: 1fr;
}

/* --- Electronic verification badge --- */
.doc-page .doc-verified-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: max-content;
  max-width: 100%;
  box-sizing: border-box;
  margin: 1.1rem auto 0;
  padding: 0.4rem 0.9rem;
  border-radius: 9999px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.doc-page .doc-verified-badge svg {
  width: 0.85rem;
  height: 0.85rem;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .doc-page .doc-parties-grid,
  .doc-page .sign-block {
    grid-template-columns: 1fr;
  }
}

/* =====================================================================
   PDF export clone: isolated, fixed-size A4 print layout
   ---------------------------------------------------------------------
   Applied only to the throwaway off-screen clone built by
   buildPdfExportClone() in app.js, never to the live on-screen preview.
   Fixed pt typography (rather than the live preview's flexible rem-based
   sizing) means html2canvas always measures and paginates an identical
   layout no matter the visitor's viewport, zoom, or browser — this is
   what eliminates the blank first page and mid-line text cuts between
   pages. Every rule here is !important so no cascade/specificity quirk
   in a real browser can defeat it.

   Width is deliberately 100%, NOT a fixed mm value: html2pdf's own
   internal toContainer() step re-wraps whatever we hand it in a div
   sized to exactly (page width − left/right margin) and captures THAT
   div with html2canvas — so a clone forced to a fixed 210mm here would
   be wider than that wrapper and get clipped down its right edge the
   moment opt.margin has any horizontal component (which PDF_MARGIN_MM
   in app.js does). width:100% lets the clone fill whatever width
   html2pdf's own wrapper gives it, which is still fully deterministic
   and viewport-independent (it's derived from the A4 page format and
   our own fixed margin config, never from the live page's layout). */
.pdf-export-clone {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  /* Only a small interior breathing space here — the real page margin
     (including the 25mm bottom band the jsPDF footer overlay lives in)
     is html2pdf's own repeating per-page `margin` option (PDF_MARGIN_MM
     in app.js), NOT this padding. Stacking a large padding on top of
     that margin would double-count it on every page. */
  padding: 4mm !important;
  font-size: 10pt !important;
}

/* Never split these across a page — forced page-break-inside:avoid so a
   paragraph, clause, card, heading, or table row always moves whole to
   the next page instead of being sliced mid-line. */
.pdf-export-clone .doc-letterhead,
.pdf-export-clone .doc-parties-grid,
.pdf-export-clone .party-card,
.pdf-export-clone .clause-block,
.pdf-export-clone .clause-header,
.pdf-export-clone p,
.pdf-export-clone h2,
.pdf-export-clone h3,
.pdf-export-clone h4,
.pdf-export-clone .sign-block,
.pdf-export-clone .sign-card,
.pdf-export-clone .bilingual-table tr,
.pdf-export-clone .doc-verified-badge,
.pdf-export-clone .doc-integrity-block {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
}
/* Only elements that are already naturally block-level get display:block
   forced — flex/grid layout containers (.doc-letterhead, .doc-parties-grid,
   .sign-block, .clause-header) and table rows/cells are deliberately
   excluded, since forcing block display on those would corrupt their
   side-by-side layout (letterhead logo+meta, the two party cards, the two
   signature cards, the bilingual table columns). */
.pdf-export-clone .clause-block,
.pdf-export-clone .doc-verified-badge,
.pdf-export-clone p,
.pdf-export-clone h2,
.pdf-export-clone h3,
.pdf-export-clone h4 {
  display: block !important;
}
/* Keep the clause number + title glued to the paragraph that follows it. */
.pdf-export-clone .clause-header {
  page-break-after: avoid !important;
  break-after: avoid !important;
}
/* Nothing should ever force a break before the very first element (this
   is what produces a blank leading page) — the clone's letterhead is
   always the first child. */
.pdf-export-clone > *:first-child {
  page-break-before: avoid !important;
  break-before: avoid !important;
}
/* Extra trailing safety clearance below the very last element, on top of
   html2pdf's own per-page bottom margin, so the verified badge (and
   whatever precedes it) never sits flush against the footer band. */
.pdf-export-clone > *:last-child {
  margin-bottom: 20mm !important;
}
/* The mobile single-column overrides above key off the real browser
   viewport (@media max-width:640px) — html2pdf's toContainer() wrapper
   has its own fixed width, but a CSS media query always evaluates
   against the actual browser window, not an ancestor's width. Without
   this, exporting a PDF from a narrow browser window (or a phone) would
   silently collapse the two-column party cards, signature cards, and
   bilingual table into single-column/stacked layout in the OUTPUT FILE
   — the opposite of the deterministic, viewport-independent export this
   whole clone exists for. Force the desktop layout back, always. */
.pdf-export-clone .doc-parties-grid,
.pdf-export-clone .sign-block {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
}
/* Privacy Policy's single-card layout must still collapse to one column
   inside the export clone — more specific than the forced 2-column rule
   above, so it wins regardless of source order. */
.pdf-export-clone .doc-parties-grid.single,
.pdf-export-clone .sign-block.single {
  grid-template-columns: 1fr !important;
}
.pdf-export-clone .bilingual-table,
.pdf-export-clone .bilingual-table tbody {
  display: table !important;
  width: 100% !important;
}
.pdf-export-clone .bilingual-table tr {
  display: table-row !important;
  width: auto !important;
}
.pdf-export-clone .bilingual-table td.bilingual-cell {
  display: table-cell !important;
  width: 50% !important;
}
.pdf-export-clone .bilingual-table td.bilingual-cell:first-child {
  border-right: 1px solid #f1f5f9 !important;
  border-bottom: none !important;
  padding: 0.4rem 0.9rem 0.4rem 0 !important;
  margin-bottom: 0 !important;
}
.pdf-export-clone .bilingual-table td.bilingual-cell:last-child {
  padding: 0.4rem 0 0.4rem 0.9rem !important;
}

/* ===== Prose (guide/FAQ) ===== */
.prose-legal h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: rgb(15 23 42);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}
.dark .prose-legal h2 { color: white; }
.prose-legal h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: rgb(15 23 42);
  margin-top: 1.75rem;
  margin-bottom: 0.6rem;
}
.dark .prose-legal h3 { color: rgb(241 245 249); }
.prose-legal p {
  color: rgb(71 85 105);
  line-height: 1.75;
  margin-bottom: 1rem;
}
.dark .prose-legal p { color: rgb(148 163 184); }
.prose-legal ul {
  list-style: disc;
  padding-left: 1.4rem;
  color: rgb(71 85 105);
  line-height: 1.75;
}
.dark .prose-legal ul { color: rgb(148 163 184); }
.prose-legal ul li { margin-bottom: 0.35rem; }

/* FAQ accordion */
.faq-item {
  border: 1px solid rgb(226 232 240);
  border-radius: 0.75rem;
  background: rgb(248 250 252);
  overflow: hidden;
}
.dark .faq-item {
  border-color: rgb(30 41 59);
  background: rgb(2 6 23 / 0.3);
}
.faq-question {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  text-align: left;
  padding: 0.9rem 1.1rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: rgb(15 23 42);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.dark .faq-question { color: white; }
.faq-icon {
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  color: rgb(37 99 235);
  transition: transform 0.25s ease;
}
.faq-item.open .faq-icon {
  transform: rotate(180deg);
}
.faq-answer {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding: 0 1.1rem;
  transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.3s ease;
}
.faq-item.open .faq-answer {
  max-height: 480px;
  opacity: 1;
  padding: 0 1.1rem 1rem;
}
.faq-answer p {
  margin: 0;
  color: rgb(71 85 105);
  font-size: 0.88rem;
  line-height: 1.6;
}
.dark .faq-answer p { color: rgb(148 163 184); }

.disclaimer-box {
  border-left: 4px solid rgb(217 119 6);
  background: rgb(255 251 235);
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  color: rgb(120 53 15);
}

/* ===== Discreet collapsible disclaimer, just above the footer ===== */
.disclaimer-collapsible {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 1rem;
}
.disclaimer-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.7rem 0;
  background: none;
  border: none;
  border-top: 1px solid rgb(226 232 240);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgb(100 116 139);
  cursor: pointer;
}
.dark .disclaimer-toggle {
  border-top-color: rgb(30 41 59);
  color: rgb(148 163 184);
}
.disclaimer-toggle-icon {
  width: 0.85rem;
  height: 0.85rem;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.disclaimer-toggle[aria-expanded="true"] .disclaimer-toggle-icon {
  transform: rotate(180deg);
}
.disclaimer-collapsible .disclaimer-box {
  margin-bottom: 1rem;
}
/* ===== Legal Guide accordion ===== */
.guide-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.5rem 0 2.5rem;
}
.guide-item {
  border-radius: 0.85rem;
  overflow: hidden;
  border: 1px solid rgb(30 41 59 / 0.15);
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.06);
}
.dark .guide-item {
  border-color: rgb(51 65 85 / 0.6);
  box-shadow: none;
}
.guide-question {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  text-align: left;
  padding: 1rem 1.25rem;
  font-weight: 700;
  font-size: 0.98rem;
  color: rgb(241 245 249);
  background: #1e293b;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}
.guide-question:hover {
  background: #263449;
}
.dark .guide-question {
  background: #2b3b52;
}
.dark .guide-question:hover {
  background: #33455f;
}
.guide-icon {
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  color: rgb(96 165 250);
  transition: transform 0.25s ease;
}
.guide-item.open .guide-icon {
  transform: rotate(180deg);
}
.guide-panel {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  background: rgb(248 250 252);
  transition: max-height 0.3s ease, opacity 0.25s ease;
}
.dark .guide-panel {
  background: rgb(2 6 23 / 0.3);
}
.guide-item.open .guide-panel {
  opacity: 1;
}
.guide-panel-inner {
  padding: 1.1rem 1.25rem 1.25rem;
}
.guide-panel-inner p {
  margin: 0 0 0.9rem;
  color: rgb(71 85 105);
  font-size: 0.9rem;
  line-height: 1.7;
}
.guide-panel-inner p:last-child { margin-bottom: 0; }
.dark .guide-panel-inner p { color: rgb(148 163 184); }
.guide-panel-inner ul {
  margin: 0 0 0.9rem;
  padding-left: 1.2rem;
  color: rgb(71 85 105);
  font-size: 0.9rem;
  line-height: 1.7;
  list-style: disc;
}
.dark .guide-panel-inner ul { color: rgb(148 163 184); }
.guide-panel-inner ul:last-child { margin-bottom: 0; }
.guide-panel-inner ul li { margin-bottom: 0.35rem; }
.guide-subheading {
  font-weight: 800;
  font-size: 0.92rem;
  color: rgb(15 23 42);
  margin: 0 0 0.5rem;
}
.dark .guide-subheading { color: white; }

.dark .disclaimer-box {
  background: rgb(69 26 3 / 0.25);
  color: rgb(253 230 138);
  border-left-color: rgb(217 119 6);
}

/* ===== Benefits section ===== */
.benefit-card {
  padding: 1.5rem 1.25rem;
  border-radius: 1rem;
  border: 1.5px solid rgb(226 232 240);
  background: white;
  text-align: center;
  transition: all 0.15s ease;
}
.dark .benefit-card {
  background: rgb(15 23 42);
  border-color: rgb(30 41 59);
}
.benefit-card:hover {
  border-color: rgb(147 197 253);
  box-shadow: 0 8px 20px -8px rgb(37 99 235 / 0.25);
  transform: translateY(-2px);
}
.dark .benefit-card:hover {
  border-color: rgb(59 130 246);
}
.benefit-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.75rem;
  width: 2.75rem;
  border-radius: 0.85rem;
  background: rgb(59 130 246 / 0.1);
  border: 1px solid rgb(59 130 246 / 0.2);
  color: rgb(59 130 246);
  margin-bottom: 0.85rem;
}
.dark .benefit-icon {
  background: rgb(59 130 246 / 0.12);
  color: rgb(96 165 250);
}
.benefit-icon svg {
  width: 1.35rem;
  height: 1.35rem;
}
.benefit-card h3 {
  font-size: 0.95rem;
  font-weight: 800;
  color: rgb(15 23 42);
  margin-bottom: 0.4rem;
}
.dark .benefit-card h3 { color: white; }
.benefit-card p {
  font-size: 0.82rem;
  line-height: 1.5;
  color: rgb(100 116 139);
}
.dark .benefit-card p { color: rgb(148 163 184); }

/* ===== Newsletter signup (footer) ===== */
.newsletter-footer-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  padding: 1.5rem;
  border-radius: 1rem;
  border: 1.5px solid rgb(226 232 240);
  background: linear-gradient(135deg, rgb(239 246 255), rgb(255 255 255));
}
.dark .newsletter-footer-card {
  border-color: rgb(30 41 59);
  background: linear-gradient(135deg, rgb(30 41 59 / 0.5), rgb(15 23 42));
}
.newsletter-footer-text strong {
  display: block;
  font-size: 1rem;
  font-weight: 800;
  color: rgb(15 23 42);
  margin-bottom: 0.25rem;
}
.dark .newsletter-footer-text strong { color: white; }
.newsletter-footer-text p {
  font-size: 0.85rem;
  color: rgb(100 116 139);
}
.dark .newsletter-footer-text p { color: rgb(148 163 184); }
.newsletter-footer-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
  max-width: 100%;
}
.newsletter-footer-input {
  min-width: 0;
}
@media (min-width: 640px) {
  .newsletter-footer-card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
  }
  .newsletter-footer-form {
    flex-direction: row;
    flex-shrink: 0;
    width: auto;
    min-width: 22rem;
  }
  .newsletter-footer-input {
    flex: 1;
  }
}

/* ===== Donation button & modal ===== */
.donate-btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: rgb(120 53 15);
  background: rgb(254 240 138);
  border: 1.5px solid rgb(250 204 21 / 0.6);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.donate-btn-nav:hover {
  background: rgb(253 224 71);
  transform: translateY(-1px);
}
.dark .donate-btn-nav {
  color: rgb(254 240 138);
  background: rgb(120 53 15 / 0.35);
  border-color: rgb(202 138 4 / 0.6);
}
.dark .donate-btn-nav:hover {
  background: rgb(120 53 15 / 0.55);
}
@media (max-width: 767px) {
  .donate-btn-nav {
    padding: 0;
    height: 2rem;
    width: 2rem;
    justify-content: center;
    gap: 0;
  }
  .donate-btn-nav .donate-icon svg {
    width: 0.95rem;
    height: 0.95rem;
  }
}
.donate-btn-footer {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: rgb(120 53 15);
  background: rgb(254 240 138);
  border: 1.5px solid rgb(250 204 21 / 0.6);
  cursor: pointer;
  transition: all 0.15s ease;
}
.donate-btn-footer:hover {
  background: rgb(253 224 71);
}
.dark .donate-btn-footer {
  color: rgb(254 240 138);
  background: rgb(120 53 15 / 0.35);
  border-color: rgb(202 138 4 / 0.6);
}
.dark .donate-btn-footer:hover {
  background: rgb(120 53 15 / 0.55);
}
.donate-icon {
  display: inline-flex;
  line-height: 1;
}
.donate-icon svg {
  width: 1rem;
  height: 1rem;
}
.donate-modal-desc {
  font-size: 0.85rem;
  line-height: 1.55;
  color: rgb(71 85 105);
}
.dark .donate-modal-desc { color: rgb(148 163 184); }
.donate-amounts {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.donate-amount-btn {
  padding: 0.55rem 1.1rem;
  border-radius: 0.6rem;
  border: 1.5px solid rgb(226 232 240);
  background: white;
  font-size: 0.9rem;
  font-weight: 700;
  color: rgb(51 65 85);
  cursor: pointer;
  transition: all 0.15s ease;
}
.dark .donate-amount-btn {
  background: rgb(15 23 42);
  border-color: rgb(30 41 59);
  color: rgb(226 232 240);
}
.donate-amount-btn:hover {
  border-color: rgb(147 197 253);
}
.donate-amount-btn.active {
  background: rgb(37 99 235);
  border-color: rgb(37 99 235);
  color: white;
}
.donate-amount-custom {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0 0.7rem;
  border-radius: 0.6rem;
  border: 1.5px solid rgb(226 232 240);
  color: rgb(51 65 85);
  font-weight: 600;
}
.dark .donate-amount-custom {
  border-color: rgb(30 41 59);
  color: rgb(226 232 240);
}
.donate-amount-custom input {
  width: 4.5rem;
  padding: 0.55rem 0;
  border: none;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 700;
  color: inherit;
  outline: none;
}
.donate-thanks {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 0.6rem;
  background: rgb(220 252 231);
  color: rgb(22 101 52);
  font-size: 0.85rem;
  font-weight: 600;
}
.dark .donate-thanks {
  background: rgb(20 83 45 / 0.35);
  color: rgb(134 239 172);
}
.donate-thanks.hidden { display: none; }

/* ===== Small ghost button variant ===== */
.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
}

/* ===== Autosave toolbar ===== */
.autosave-indicator {
  font-size: 0.72rem;
  color: rgb(148 163 184);
  font-style: italic;
}

/* ===== Completion progress bar ===== */
.completion-bar-wrap {
  padding: 1rem 1.25rem 0;
}
.completion-bar-track {
  height: 6px;
  border-radius: 9999px;
  background: rgb(226 232 240);
  overflow: hidden;
}
.dark .completion-bar-track {
  background: rgb(30 41 59);
}
.completion-bar-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, rgb(37 99 235), rgb(16 185 129));
  transition: width 0.35s ease;
}
.completion-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgb(100 116 139);
  margin-top: 0.4rem;
}
.dark .completion-bar-label {
  color: rgb(148 163 184);
}

/* ===== Field validation error ===== */
.field-input.field-error {
  border-color: rgb(220 38 38);
  animation: field-error-pulse 1.4s ease-in-out infinite;
}
.sig-slot.field-error {
  border-color: rgb(220 38 38) !important;
  animation: field-error-pulse 1.4s ease-in-out infinite;
}
@keyframes field-error-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgb(220 38 38 / 0.12); }
  50% { box-shadow: 0 0 0 4px rgb(220 38 38 / 0.3); }
}

/* ===== Validation alert (missing required fields before download) ===== */
.validation-alert {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  left: auto;
  max-width: 22rem;
  width: calc(100% - 2rem);
  background: rgb(254 242 242 / 0.97);
  border: 1px solid rgb(239 68 68);
  border-radius: 0.85rem;
  padding: 1rem 1.75rem 1rem 1.1rem;
  box-shadow: 0 20px 40px -12px rgb(0 0 0 / 0.35);
  z-index: 300;
  opacity: 0;
  transform: translateY(-14px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.dark .validation-alert {
  background: rgb(69 10 10 / 0.85);
  backdrop-filter: blur(6px);
}
.validation-alert.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
@media (max-width: 640px) {
  .validation-alert {
    left: 1rem;
    right: 1rem;
    max-width: none;
    width: auto;
  }
}
.validation-alert-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.validation-alert-icon {
  display: inline-flex;
  color: rgb(220 38 38);
  line-height: 1;
  flex-shrink: 0;
}
.validation-alert-icon svg {
  width: 1.2rem;
  height: 1.2rem;
}
.validation-alert-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: rgb(185 28 28);
}
.dark .validation-alert-title { color: rgb(248 113 113); }
.validation-alert-intro {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgb(153 27 27);
  margin-bottom: 0.35rem;
}
.dark .validation-alert-intro { color: rgb(252 165 165); }
.validation-alert-list {
  list-style: disc;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: rgb(127 29 29);
  line-height: 1.55;
}
.dark .validation-alert-list { color: rgb(254 202 202); }
.validation-alert-close {
  position: absolute;
  top: 0.55rem;
  right: 0.65rem;
  font-size: 1.25rem;
  line-height: 1;
  background: none;
  border: none;
  color: rgb(153 27 27);
  opacity: 0.7;
  cursor: pointer;
}
.dark .validation-alert-close { color: rgb(252 165 165); }
.validation-alert-close:hover { opacity: 1; }

/* ===== Logo upload ===== */
.logo-upload-box {
  margin-bottom: 1.25rem;
}
.logo-upload-btn, .sig-upload-wrap .logo-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border: 1.5px dashed rgb(148 163 184);
  border-radius: 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: rgb(71 85 105);
  cursor: pointer;
  transition: all 0.15s ease;
}
.logo-upload-btn:hover {
  border-color: rgb(59 130 246);
  color: rgb(37 99 235);
}
.dark .logo-upload-btn {
  border-color: rgb(51 65 85);
  color: rgb(148 163 184);
}
.dark .logo-upload-btn:hover {
  border-color: rgb(59 130 246);
  color: rgb(96 165 250);
}
.logo-preview-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid rgb(226 232 240);
  border-radius: 0.6rem;
  background: rgb(248 250 252);
}
.dark .logo-preview-wrap {
  border-color: rgb(30 41 59);
  background: rgb(2 6 23 / 0.3);
}
.logo-preview-wrap img {
  max-height: 44px;
  max-width: 140px;
  object-fit: contain;
}

/* ===== Signature slots ===== */
.sig-slots {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}
@media (min-width: 640px) {
  .sig-slots { grid-template-columns: 1fr 1fr; }
  .sig-slots.sig-slots-single { grid-template-columns: 1fr; }
}
.sig-slot {
  border: 1.5px solid rgb(226 232 240);
  border-radius: 0.75rem;
  padding: 0.75rem;
}
.dark .sig-slot {
  border-color: rgb(30 41 59);
}
.sig-slot-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: rgb(71 85 105);
  margin-bottom: 0.5rem;
}
.dark .sig-slot-label { color: rgb(148 163 184); }
.sig-add-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.9rem;
  border: 1.5px dashed rgb(148 163 184);
  border-radius: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: rgb(37 99 235);
  background: rgb(239 246 255);
  cursor: pointer;
}
.dark .sig-add-btn {
  background: rgb(30 58 138 / 0.2);
  border-color: rgb(51 65 85);
  color: rgb(96 165 250);
}
.sig-thumb-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.sig-thumb-box img {
  max-height: 70px;
  max-width: 100%;
  object-fit: contain;
  background: white;
  border: 1px solid rgb(226 232 240);
  border-radius: 0.4rem;
  padding: 0.25rem;
}
.sig-thumb-actions {
  display: flex;
  gap: 0.5rem;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgb(15 23 42 / 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 200;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: rgb(255 255 255 / 0.94);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgb(226 232 240 / 0.8);
  border-top: 1px solid rgb(255 255 255 / 0.9);
  border-radius: 1rem;
  padding: 1.25rem;
  width: 100%;
  max-width: 32rem;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.4);
}
.dark .modal-box {
  background: rgb(15 23 42 / 0.9);
  border-color: rgb(30 41 59 / 0.9);
  border-top-color: rgb(255 255 255 / 0.1);
}
/* Terms/Privacy modals: content is long prose, so the box caps itself to
   the viewport height and only the body scrolls — the header (title + ×)
   stays put instead of scrolling away with the text. */
.modal-box.legal-modal-box {
  max-width: 40rem;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.legal-modal-box .modal-header {
  flex-shrink: 0;
}
.legal-modal-body {
  overflow-y: auto;
  padding-right: 0.5rem;
}
@media (max-width: 480px) {
  .modal-box.legal-modal-box { max-height: 80vh; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: rgb(15 23 42);
}
.dark .modal-header h3 { color: white; }
.modal-close {
  font-size: 1.5rem;
  line-height: 1;
  color: rgb(100 116 139);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
}
.modal-close:hover { color: rgb(15 23 42); }
.dark .modal-close:hover { color: white; }

.sig-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.sig-tab {
  padding: 0.4rem 0.9rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: rgb(100 116 139);
  background: rgb(241 245 249);
  border: none;
  cursor: pointer;
}
.dark .sig-tab {
  background: rgb(30 41 59);
  color: rgb(148 163 184);
}
.sig-tab.active {
  background: rgb(37 99 235);
  color: white;
}

.sig-pad-wrap {
  border: 1.5px dashed rgb(148 163 184);
  border-radius: 0.6rem;
  overflow: hidden;
  background: white;
}
#signature-canvas {
  display: block;
  width: 100%;
  height: 200px;
  touch-action: none;
  cursor: crosshair;
}
.sig-hint {
  font-size: 0.75rem;
  color: rgb(100 116 139);
  margin-top: 0.5rem;
}
.dark .sig-hint { color: rgb(148 163 184); }
.sig-upload-wrap {
  margin-top: 0.5rem;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgb(226 232 240);
  flex-wrap: wrap;
}
.dark .modal-actions { border-color: rgb(30 41 59); }

/* ===== Document logo / signature images (preview + PDF) ===== */
.doc-page .doc-logo {
  display: block;
  max-height: 60px;
  max-width: 220px;
  margin: 0 auto 0.75rem;
  object-fit: contain;
}
.doc-page .sign-img {
  display: block;
  max-height: 55px;
  max-width: 90%;
  margin: 0 auto;
  object-fit: contain;
}
.doc-page .sign-blank {
  height: 55px;
}

/* ===== Scrollbar for preview ===== */
#preview-scroll::-webkit-scrollbar { width: 8px; }
#preview-scroll::-webkit-scrollbar-thumb {
  background: rgb(203 213 225);
  border-radius: 9999px;
}
.dark #preview-scroll::-webkit-scrollbar-thumb {
  background: rgb(51 65 85);
}

/* ===== Mobile preview collapse + floating action button ===== */
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid rgb(241 245 249);
  background: rgb(248 250 252);
  border: none;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}
.dark .preview-header {
  border-bottom-color: rgb(30 41 59);
  background: rgb(2 6 23 / 0.5);
}
@media (min-width: 1024px) {
  .preview-header {
    cursor: default;
  }
}
.preview-toggle-icon {
  width: 1.1rem;
  height: 1.1rem;
  color: rgb(100 116 139);
  transition: transform 0.25s ease;
  flex-shrink: 0;
}
.dark .preview-toggle-icon { color: rgb(148 163 184); }
#btn-preview-toggle[aria-expanded="true"] .preview-toggle-icon {
  transform: rotate(180deg);
}
.preview-collapsible {
  transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.3s ease;
}

.preview-fab {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.85rem 1.15rem;
  border-radius: 1rem;
  background: linear-gradient(to right, rgb(37 99 235), rgb(79 70 229));
  color: white;
  font-size: 0.9rem;
  font-weight: 700;
  border: 1px solid rgb(255 255 255 / 0.15);
  box-shadow: 0 10px 25px -8px rgb(37 99 235 / 0.5);
  cursor: pointer;
  transition: all 0.2s ease-out;
}
.preview-fab:hover {
  background: linear-gradient(to right, rgb(59 130 246), rgb(99 102 241));
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -6px rgb(59 130 246 / 0.55);
}
.preview-fab.hidden { display: none; }
.preview-fab-icon {
  display: inline-flex;
}
.preview-fab-icon svg {
  width: 1.05rem;
  height: 1.05rem;
}

/* ===== Mobile bottom sheet (secondary export/utility actions) ===== */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgb(15 23 42 / 0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-overlay.hidden { display: none; }
.sheet-panel {
  background: rgb(255 255 255 / 0.98);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgb(226 232 240 / 0.8);
  border-bottom: none;
  border-radius: 1.25rem 1.25rem 0 0;
  width: 100%;
  max-width: 32rem;
  padding: 0.75rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -20px 40px -12px rgb(0 0 0 / 0.35);
  animation: sheet-slide-up 0.25s ease-out;
}
.dark .sheet-panel {
  background: rgb(15 23 42 / 0.96);
  border-color: rgb(30 41 59 / 0.9);
}
@keyframes sheet-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.sheet-handle {
  width: 2.5rem;
  height: 0.3rem;
  background: rgb(203 213 225);
  border-radius: 9999px;
  margin: 0 auto 0.75rem;
}
.dark .sheet-handle { background: rgb(51 65 85); }
.sheet-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: rgb(15 23 42);
  margin-bottom: 0.65rem;
  text-align: center;
}
.dark .sheet-title { color: white; }
.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 60vh;
  overflow-y: auto;
}
.sheet-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: 0.65rem;
  background: rgb(248 250 252);
  border: 1px solid rgb(226 232 240);
  color: rgb(30 41 59);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.dark .sheet-btn {
  background: rgb(30 41 59 / 0.6);
  border-color: rgb(51 65 85);
  color: rgb(226 232 240);
}
.sheet-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.sheet-btn svg { width: 1.1rem; height: 1.1rem; flex-shrink: 0; }
.sheet-btn-danger { color: rgb(220 38 38); }
.dark .sheet-btn-danger { color: rgb(248 113 113); }
.sheet-close-btn {
  margin-top: 0.6rem;
  width: 100%;
  padding: 0.7rem;
  border-radius: 0.65rem;
  background: transparent;
  border: 1px solid rgb(226 232 240);
  color: rgb(100 116 139);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.dark .sheet-close-btn { border-color: rgb(51 65 85); color: rgb(148 163 184); }
@media (min-width: 640px) {
  .sheet-overlay { display: none !important; }
}

/* ===== Section subtitle (shared by new step-4 blocks) ===== */
.section-subtitle {
  font-size: 0.9rem;
  font-weight: 800;
  color: rgb(15 23 42);
  margin-bottom: 0.25rem;
}
.dark .section-subtitle { color: white; }
.section-subtitle-hint {
  font-size: 0.78rem;
  color: rgb(100 116 139);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}
.dark .section-subtitle-hint { color: rgb(148 163 184); }

/* ===== Optional clauses ===== */
.optional-clauses-box {
  border: 1.5px solid rgb(226 232 240);
  border-radius: 0.75rem;
  padding: 1rem 1.1rem;
  background: rgb(248 250 252);
}
.dark .optional-clauses-box {
  border-color: rgb(30 41 59);
  background: rgb(2 6 23 / 0.3);
}
.optional-clause-toggle {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-top: 1px solid rgb(226 232 240);
  cursor: pointer;
  user-select: none;
}
.optional-clause-toggle:first-of-type { border-top: none; }
.dark .optional-clause-toggle { border-top-color: rgb(30 41 59); }
.optional-clause-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.optional-clause-toggle .bilingual-switch { margin-top: 0.15rem; }
.optional-clause-toggle input:checked + .bilingual-switch {
  background: rgb(37 99 235);
}
.optional-clause-toggle input:checked + .bilingual-switch::before {
  transform: translateX(1.05rem);
}
.optional-clause-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.optional-clause-toggle-text strong {
  font-size: 0.85rem;
  font-weight: 700;
  color: rgb(15 23 42);
}
.dark .optional-clause-toggle-text strong { color: white; }
.optional-clause-toggle-text small {
  font-size: 0.75rem;
  color: rgb(100 116 139);
  line-height: 1.4;
}
.dark .optional-clause-toggle-text small { color: rgb(148 163 184); }

/* ===== Custom clauses ===== */
.custom-clauses-list {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.custom-clause-empty {
  font-size: 0.78rem;
  color: rgb(148 163 184);
  font-style: italic;
  margin-top: 0.5rem;
}
.custom-clause-item {
  border: 1.5px solid rgb(226 232 240);
  border-radius: 0.6rem;
  padding: 0.75rem;
  background: white;
}
.dark .custom-clause-item {
  border-color: rgb(30 41 59);
  background: rgb(15 23 42);
}
.custom-clause-item-row {
  display: flex;
  gap: 0.5rem;
}
.custom-clause-item-row .field-input { flex: 1; }
.custom-clause-body-input {
  resize: vertical;
  min-height: 4.5rem;
}

/* ===== Penalty clause calculator (collapsible) ===== */
.penalty-calc-box {
  border: 1.5px solid rgb(226 232 240);
  border-radius: 0.75rem;
  overflow: hidden;
}
.dark .penalty-calc-box { border-color: rgb(30 41 59); }
.penalty-calc-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.1rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: rgb(15 23 42);
  background: rgb(248 250 252);
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.dark .penalty-calc-header {
  color: white;
  background: rgb(2 6 23 / 0.3);
}
.penalty-calc-icon {
  width: 1rem;
  height: 1rem;
  color: rgb(100 116 139);
  transition: transform 0.25s ease;
  flex-shrink: 0;
}
.penalty-calc-header[aria-expanded="true"] .penalty-calc-icon {
  transform: rotate(180deg);
}
.penalty-calc-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.penalty-calc-inner {
  padding: 1rem 1.1rem;
}
.penalty-result {
  margin-top: 0.9rem;
  padding: 0.75rem 0.9rem;
  border-radius: 0.5rem;
  background: rgb(239 246 255);
  font-size: 0.82rem;
}
.dark .penalty-result { background: rgb(30 58 138 / 0.2); }
.penalty-result p { margin: 0.4rem 0 0.6rem; color: rgb(51 65 85); line-height: 1.5; }
.dark .penalty-result p { color: rgb(203 213 225); }
.penalty-result.hidden { display: none; }

/* ===== Pre-download checklist ===== */
.checklist-box {
  border: 1.5px solid rgb(226 232 240);
  border-radius: 0.75rem;
  padding: 1rem 1.1rem;
  background: rgb(248 250 252);
}
.dark .checklist-box {
  border-color: rgb(30 41 59);
  background: rgb(2 6 23 / 0.3);
}
.checklist-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0;
  font-size: 0.83rem;
  color: rgb(51 65 85);
  cursor: pointer;
  user-select: none;
}
.dark .checklist-item { color: rgb(226 232 240); }
.checklist-item input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: rgb(37 99 235);
  flex-shrink: 0;
  cursor: pointer;
}
.checklist-hint {
  font-size: 0.72rem;
  color: rgb(148 163 184);
  margin-top: 0.4rem;
  font-style: italic;
}

/* ===== Share link modal ===== */
.share-link-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}
.share-link-row .field-input {
  flex: 1;
  font-size: 0.78rem;
  font-family: monospace;
}
.share-link-row .btn-primary { white-space: nowrap; }

/* ===== Watermark (live preview) ===== */
.doc-page { position: relative; }
.doc-page .doc-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-45deg);
  font-size: 4rem;
  font-weight: 800;
  color: #cbd5e1;
  opacity: 0.15;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  z-index: 1;
  letter-spacing: 0.05em;
}

/* ===== Integrity seal (QR + hash + timestamp) ===== */
.doc-integrity-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed #e2e8f0;
}
.doc-qr-slot {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.doc-qr-img {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}
.doc-integrity-text {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  font-size: 0.62rem;
  color: #94a3b8;
  line-height: 1.5;
}
.doc-integrity-line { white-space: nowrap; }

/* ===== Legal glossary: 2-column card grid ===== */
.glossary-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}
@media (min-width: 768px) {
  .glossary-list { grid-template-columns: 1fr 1fr; }
}
.glossary-item {
  padding: 1.1rem;
  border: 1.5px solid rgb(226 232 240);
  border-radius: 0.85rem;
  background: white;
  transition: all 0.2s ease-out;
}
.dark .glossary-item {
  border-color: rgb(30 41 59);
  background: rgb(15 23 42);
}
.glossary-item:hover {
  border-color: rgb(59 130 246 / 0.5);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -8px rgb(59 130 246 / 0.25);
}
.glossary-item dt {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  color: rgb(15 23 42);
  font-size: 0.9rem;
  scroll-margin-top: 5rem;
}
.dark .glossary-item dt {
  color: white;
}
.glossary-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  flex-shrink: 0;
  border-radius: 0.65rem;
  background: rgb(59 130 246 / 0.1);
  border: 1px solid rgb(59 130 246 / 0.2);
  color: rgb(59 130 246);
}
.dark .glossary-icon {
  background: rgb(59 130 246 / 0.12);
  color: rgb(96 165 250);
}
.glossary-icon svg {
  width: 1.05rem;
  height: 1.05rem;
}
.glossary-item dd {
  margin: 0.5rem 0 0;
  color: rgb(71 85 105);
  font-size: 0.8rem;
  line-height: 1.55;
}
.dark .glossary-item dd {
  color: rgb(148 163 184);
}
.glossary-item.hidden {
  display: none;
}

/* ===== Post-download email capture banner ===== */
.email-capture-banner {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 90;
  width: 21rem;
  max-width: calc(100vw - 2rem);
  background: rgb(255 255 255 / 0.9);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgb(226 232 240 / 0.8);
  border-top: 1px solid rgb(255 255 255 / 0.9);
  border-radius: 0.9rem;
  box-shadow: 0 12px 30px -8px rgb(0 0 0 / 0.2);
  padding: 1.1rem 1.2rem;
  opacity: 0;
  transform: translateY(0.75rem);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.dark .email-capture-banner {
  background: rgb(15 23 42 / 0.85);
  border-color: rgb(30 41 59 / 0.9);
  border-top-color: rgb(255 255 255 / 0.1);
}
.email-capture-banner.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.email-capture-close {
  position: absolute;
  top: 0.6rem;
  right: 0.7rem;
  font-size: 1.1rem;
  line-height: 1;
  color: rgb(148 163 184);
  background: none;
  border: none;
  cursor: pointer;
}
.email-capture-title {
  display: block;
  font-size: 0.95rem;
  color: rgb(15 23 42);
  padding-right: 1.25rem;
}
.dark .email-capture-title {
  color: white;
}
.email-capture-desc {
  margin: 0.35rem 0 0.85rem;
  font-size: 0.78rem;
  color: rgb(100 116 139);
  line-height: 1.5;
}
.dark .email-capture-desc {
  color: rgb(148 163 184);
}
.email-capture-form {
  display: flex;
  gap: 0.5rem;
}
.email-capture-input {
  flex: 1;
  min-width: 0;
}
.email-capture-submit {
  white-space: nowrap;
}

/* =====================================================================
   Native print: show only the generated document, reset it to a plain
   printable layout, and hide the rest of the wizard/marketing chrome
   entirely (header, ads, forms, modals, the email-capture banner...).
   ===================================================================== */
@media print {
  body * {
    visibility: hidden;
  }
  #pdf-content, #pdf-content * {
    visibility: visible;
  }
  #pdf-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    margin: 0 !important;
  }
  #preview-scroll {
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
  }
  .email-capture-banner,
  .validation-alert,
  #ndagen-toast {
    display: none !important;
  }
  @page {
    margin: 15mm;
  }
}

/* =====================================================================
   Compact wizard toolbar: completion bar + icon-only utility actions
   (save/load template, share link) with native title tooltips, replacing
   the old full-width text-label button row to reclaim vertical space.
   ===================================================================== */
.wizard-toolbar {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem 0;
}
.wizard-toolbar .completion-bar-wrap {
  flex: 1;
  padding: 0;
  min-width: 0;
}
.wizard-icon-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  padding-top: 0.1rem;
}
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 0.5rem;
  border: 1.5px solid rgb(226 232 240);
  background: transparent;
  color: rgb(71 85 105);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.icon-btn svg {
  width: 0.95rem;
  height: 0.95rem;
}
.dark .icon-btn {
  border-color: rgb(30 41 59);
  color: rgb(148 163 184);
}
.icon-btn:hover {
  background: rgb(248 250 252);
  border-color: rgb(147 197 253);
  color: rgb(37 99 235);
}
.dark .icon-btn:hover {
  background: rgb(30 41 59 / 0.5);
  color: rgb(96 165 250);
}

/* =====================================================================
   Live preview toolbar: bilingual toggle, zoom controls, and quick PDF/
   Word download shortcuts, docked to the top of the preview card so the
   most-used actions never require scrolling back up to Step 4.
   ===================================================================== */
.preview-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgb(241 245 249);
  background: rgb(250 250 252);
}
.dark .preview-toolbar {
  border-bottom-color: rgb(30 41 59);
  background: rgb(2 6 23 / 0.3);
}
.preview-toolbar .bilingual-toolbar {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  flex: 1;
  min-width: 9rem;
}
.preview-zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}
.zoom-level-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: rgb(100 116 139);
  min-width: 2.4rem;
  text-align: center;
}
.dark .zoom-level-label {
  color: rgb(148 163 184);
}
.preview-quick-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.preview-quick-actions .icon-btn {
  width: 2rem;
  height: 2rem;
}
.preview-quick-actions .icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* =====================================================================
   Informational tab navigation (replaces the long Benefits / Guide /
   FAQ / Glossary vertical stack with one switchable panel set).
   ===================================================================== */
.info-tab-nav {
  display: flex;
  gap: 0.25rem;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1.5px solid rgb(226 232 240);
  margin-bottom: 2rem;
}
.info-tab-nav::-webkit-scrollbar {
  display: none;
}
.dark .info-tab-nav {
  border-bottom-color: rgb(30 41 59);
}
.info-tab {
  flex-shrink: 0;
  padding: 0.85rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgb(100 116 139);
  border-bottom: 2px solid transparent;
  margin-bottom: -1.5px;
  background: none;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.dark .info-tab {
  color: rgb(148 163 184);
}
.info-tab:hover {
  color: rgb(37 99 235);
}
.info-tab.active {
  color: rgb(37 99 235);
  border-bottom-color: rgb(37 99 235);
}
.dark .info-tab.active {
  color: rgb(96 165 250);
  border-bottom-color: rgb(96 165 250);
}
.info-tab-panel.hidden {
  display: none;
}

/* =====================================================================
   Premium visual pass: ambient background glow, glassmorphism surfaces,
   and a polished frame for the live document preview. Deliberately
   scoped to the app's CHROME only — never to #pdf-content/.doc-page,
   which must stay a plain, high-contrast "paper" surface regardless of
   site theme (it's what gets exported to PDF and printed).
   ===================================================================== */

/* --- Ambient background glow orbs (decorative, never intercept clicks) --- */
.ambient-glow {
  position: fixed;
  width: 42rem;
  height: 42rem;
  border-radius: 9999px;
  filter: blur(120px);
  pointer-events: none;
  /* Negative z-index keeps this behind ALL normal in-flow page content
     (header, hero, cards, footer...) without needing to touch any of
     their own positioning/z-index — simpler and safer than making every
     sibling "win" a stacking fight against it. */
  z-index: -1;
  opacity: 0.06;
  transition: opacity 0.4s ease;
}
.dark .ambient-glow {
  opacity: 0.22;
}
.ambient-glow-1 {
  top: -14rem;
  left: -12rem;
  background: radial-gradient(circle, rgb(79 70 229), transparent 70%);
}
.ambient-glow-2 {
  bottom: -16rem;
  right: -12rem;
  background: radial-gradient(circle, rgb(37 99 235), transparent 70%);
}
@media (max-width: 768px) {
  .ambient-glow { width: 26rem; height: 26rem; }
}

/* --- Glassmorphism surface: wizard card + live preview card --- */
.glass-card {
  background: rgb(255 255 255 / 0.8);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgb(226 232 240 / 0.8);
  border-top: 1px solid rgb(255 255 255 / 0.9);
  border-radius: 1rem;
  box-shadow: 0 25px 50px -18px rgb(15 23 42 / 0.18);
}
.dark .glass-card {
  background: rgb(15 23 42 / 0.72);
  border-color: rgb(30 41 59 / 0.8);
  border-top-color: rgb(255 255 255 / 0.1);
  box-shadow: 0 25px 50px -18px rgb(0 0 0 / 0.55);
}

/* ===== Capabilities panel (Feature Matrix) — same frosted-glass
   language as .glass-card, themed for both light/dark instead of the
   flat dark-only treatment, with the requested blue-glow hover lift. */
.capability-card {
  padding: 1.25rem;
  border-radius: 1rem;
  background: rgb(255 255 255 / 0.7);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid rgb(226 232 240 / 0.9);
  transition: all 0.2s ease-out;
}
.dark .capability-card {
  background: rgb(15 23 42 / 0.6);
  border-color: rgb(30 41 59 / 0.8);
}
.capability-card:hover {
  border-color: rgb(59 130 246 / 0.4);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -10px rgb(37 99 235 / 0.3);
}
.capability-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.75rem;
  width: 2.75rem;
  border-radius: 0.85rem;
  background: rgb(59 130 246 / 0.1);
  border: 1px solid rgb(59 130 246 / 0.2);
  color: rgb(59 130 246);
  margin-bottom: 0.85rem;
}
.dark .capability-icon {
  background: rgb(59 130 246 / 0.12);
  color: rgb(96 165 250);
}
.capability-icon svg {
  width: 1.35rem;
  height: 1.35rem;
}
.capability-card h3 {
  font-size: 0.95rem;
  font-weight: 800;
  color: rgb(15 23 42);
  margin-bottom: 0.4rem;
}
.dark .capability-card h3 { color: white; }
.capability-card p {
  font-size: 0.82rem;
  line-height: 1.5;
  color: rgb(100 116 139);
}
.dark .capability-card p { color: rgb(148 163 184); }

/* --- Icon-only buttons: same hover lift/glow language as the rest --- */
.icon-btn {
  transition: all 0.2s ease-out;
}
.icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px -6px rgb(59 130 246 / 0.35);
}

/* --- Live preview frame: paper-on-desk feel. The frosted header/toolbar
   sit on the glass surface; #preview-scroll and the document itself
   stay a plain, undecorated white "sheet" so it always reads correctly
   and matches what gets exported. --- */
#preview-card > .glass-card {
  overflow: hidden;
}
.preview-header {
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
#preview-scroll {
  background: rgb(226 232 240 / 0.4);
}
.dark #preview-scroll {
  background: rgb(2 6 23 / 0.5);
}
#preview-scroll .doc-page {
  box-shadow: 0 20px 45px -15px rgb(0 0 0 / 0.4);
  border-radius: 0.4rem;
}

/* ===== Document history modal ===== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 20rem;
  overflow-y: auto;
  margin: 1rem 0;
}
.history-item {
  border: 1.5px solid rgb(226 232 240);
  border-radius: 0.65rem;
  padding: 0.7rem 0.85rem;
  background: rgb(248 250 252);
}
.dark .history-item {
  border-color: rgb(30 41 59);
  background: rgb(2 6 23 / 0.3);
}
.history-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
}
.history-item-top strong {
  color: rgb(15 23 42);
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 0.78rem;
}
.dark .history-item-top strong { color: white; }
.history-item-type {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 9999px;
  background: rgb(59 130 246 / 0.1);
  color: rgb(37 99 235);
  white-space: nowrap;
}
.dark .history-item-type {
  background: rgb(59 130 246 / 0.15);
  color: rgb(96 165 250);
}
.history-item-parties {
  font-size: 0.8rem;
  color: rgb(51 65 85);
  margin-top: 0.3rem;
}
.dark .history-item-parties { color: rgb(203 213 225); }
.history-item-meta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.68rem;
  color: rgb(100 116 139);
  margin-top: 0.4rem;
}
.dark .history-item-meta { color: rgb(148 163 184); }
.history-item-hash {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
}
.history-empty {
  font-size: 0.85rem;
  color: rgb(100 116 139);
  text-align: center;
  padding: 1.5rem 0;
}
.dark .history-empty { color: rgb(148 163 184); }
