  :root {
    --ink:        #0A0A0A;
    --ink-2:      #1F1F1F;
    --muted:      #6B6B6B;
    --muted-2:    #9A9A95;
    --hairline:   #E5E2DC;
    --hairline-2: #EFEDE7;
    --paper:      #FFFFFF;
    --canvas:     #EDEAE3;

    --b-violet:   #5B56A0;
    --b-magenta:  #C73E7E;
    --b-coral:    #ED6A3E;
    --brand-grad: linear-gradient(90deg, var(--b-violet) 0%, var(--b-magenta) 52%, var(--b-coral) 100%);
    --brand-grad-v: linear-gradient(180deg, var(--b-violet) 0%, var(--b-magenta) 52%, var(--b-coral) 100%);

    --accent-soft: #FAF6F1;

    --serif: "Instrument Serif", "Times New Roman", serif;
    --sans:  "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --mono:  "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

    --page-w: 210mm;
    --page-h: 297mm;
    --page-pad-x: 22mm;
    --page-pad-y: 18mm;
  }

  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  body {
    background: var(--canvas);
    font-family: var(--sans);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "ss01", "ss02", "cv11";
  }

  .doc {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    padding: 40px 16px 80px;
  }

  .sheet {
    width: var(--page-w);
    min-height: var(--page-h);
    background: var(--paper);
    position: relative;
    padding: var(--page-pad-y) var(--page-pad-x);
    box-shadow:
      0 1px 0 rgba(0,0,0,0.04),
      0 18px 40px -20px rgba(20,20,20,0.22),
      0 2px 6px -2px rgba(20,20,20,0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .sheet::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--brand-grad);
  }

  /* Typography */
  .mono { font-family: var(--mono); }
  .serif { font-family: var(--serif); }

  .eyebrow {
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .display-xl {
    font-family: var(--serif);
    font-weight: 400;
    font-size: 82px;
    line-height: 0.96;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin: 0;
  }
  .display-xl em {
    font-style: italic;
    background: var(--brand-grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  .display-l {
    font-family: var(--serif);
    font-weight: 400;
    font-size: 42px;
    line-height: 1.05;
    letter-spacing: -0.015em;
    color: var(--ink);
    margin: 0;
  }

  .section-title {
    font-family: var(--serif);
    font-weight: 400;
    font-size: 21px;
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--ink);
  }

  p, li {
    font-size: 10.5pt;
    line-height: 1.5;
    color: var(--ink-2);
    margin: 0 0 6pt;
    text-wrap: pretty;
  }
  .lede {
    font-size: 12pt;
    line-height: 1.48;
    color: var(--ink);
    font-weight: 400;
  }
  .small {
    font-size: 9pt;
    color: var(--muted);
    line-height: 1.5;
  }

  strong { font-weight: 600; color: var(--ink); }
  .defined {
    font-variant-caps: all-small-caps;
    letter-spacing: 0.04em;
    font-weight: 600;
  }
  .ph {
    font-family: var(--mono);
    font-size: 0.92em;
    letter-spacing: 0.01em;
    color: var(--ink);
    background: linear-gradient(transparent 62%, rgba(199, 62, 126, 0.13) 62%);
    padding: 0 2px;
  }

  /* Top frame */
  .page-frame {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--hairline);
  }
  .brand-mark {
    display: flex;
    align-items: center;
    gap: 0;
  }
  .brand-mark img.logo {
    height: 22px;
    width: auto;
    display: block;
  }
  .brand-mark .sep {
    width: 1px;
    height: 14px;
    background: var(--hairline);
    margin: 0 12px;
  }
  .brand-mark .sub {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .page-frame .meta {
    text-align: right;
    font-family: var(--mono);
    font-size: 10px;
    line-height: 1.5;
    color: var(--muted);
    letter-spacing: 0.04em;
  }
  .page-frame .meta b { color: var(--ink); font-weight: 500; }

  /* COVER */
  .cover { justify-content: space-between; }
  .cover .page-frame { border-bottom: 0; padding-bottom: 0; }

  .cover-stack {
    margin-top: 56px;
    display: flex;
    flex-direction: column;
    gap: 28px;
  }
  .cover-title {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 32px;
  }
  .cover-subtitle {
    font-family: var(--sans);
    font-size: 13.5px;
    color: var(--muted);
    max-width: 64ch;
    line-height: 1.55;
  }

  .cover-grid {
    margin-top: 48px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    border-top: 1px solid var(--hairline);
  }
  .cover-grid .cell {
    padding: 14px 16px 14px 0;
    border-right: 1px solid var(--hairline);
    border-bottom: 1px solid var(--hairline);
  }
  .cover-grid .cell:nth-child(4n) { border-right: 0; padding-right: 0; }
  .cover-grid .cell .k {
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin-bottom: 6px;
  }
  .cover-grid .cell .v {
    font-family: var(--sans);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink);
    line-height: 1.4;
  }
  .cover-grid .cell .v.mono { font-family: var(--mono); font-weight: 400; font-size: 11.5px; }

  .cover-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .cover-footer .badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 11px;
    border: 1px solid var(--hairline);
    border-radius: 999px;
    background: var(--paper);
  }
  .cover-footer .badge::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--brand-grad);
  }

  /* Parties */
  .parties {
    display: grid;
    grid-template-columns: 90px 1fr;
    column-gap: 24px;
    margin-top: 22px;
  }
  .parties .role {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    padding-top: 4px;
    position: relative;
  }
  .parties .party {
    padding: 12px 0 14px;
    border-bottom: 1px solid var(--hairline);
  }
  .parties .role-cell {
    padding: 12px 0 14px;
    border-bottom: 1px solid var(--hairline);
  }
  .parties .row:last-child .party,
  .parties .row:last-child .role-cell { border-bottom: 0; }
  .party-name {
    font-family: var(--serif);
    font-size: 20px;
    line-height: 1.1;
    margin: 0 0 4px;
    color: var(--ink);
  }
  .party-meta {
    font-size: 10pt;
    color: var(--muted);
    line-height: 1.5;
    margin: 0;
  }
  .party-meta b { color: var(--ink); font-weight: 500; }

  /* Body sections */
  main.body {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 11px;
  }
  .section {
    display: grid;
    grid-template-columns: 52px 1fr;
    column-gap: 18px;
  }
  .section .num {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
    letter-spacing: 0.08em;
    padding-top: 3px;
    display: flex;
    align-items: flex-start;
    gap: 7px;
  }
  .section .num .dot {
    display: inline-block;
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--brand-grad);
    margin-top: 5px;
    flex-shrink: 0;
  }
  .section-header {
    margin-bottom: 6px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--hairline);
  }
  .section-header .kicker {
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 3px;
  }

  /* Clauses */
  ol.clauses {
    list-style: none;
    padding: 0;
    margin: 4px 0 0;
    counter-reset: clause;
  }
  ol.clauses > li {
    counter-increment: clause;
    padding: 1px 0 4px;
    display: grid;
    grid-template-columns: 34px 1fr;
    column-gap: 10px;
  }
  ol.clauses > li::before {
    content: counters(clause, ".", decimal-leading-zero);
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--muted);
    padding-top: 2px;
    letter-spacing: 0.04em;
  }

  /* Compact sections */
  .section.compact { grid-template-columns: 38px 1fr; column-gap: 12px; }
  .section.compact .section-title { font-size: 15.5px; }
  .section.compact .section-header { padding-bottom: 2px; margin-bottom: 4px; }
  .section.compact .section-header .kicker { margin-bottom: 2px; }
  .section.compact p, .section.compact li { font-size: 9.5pt; line-height: 1.48; margin-bottom: 4pt; }
  .section.compact .num { font-size: 10px; padding-top: 2px; }
  .section.compact .num .dot { width: 4px; height: 4px; margin-top: 4px; }

  /* Choice row */
  .choice {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    margin: 4px 0 4px;
    padding: 10px 16px;
    border: 1px solid var(--hairline);
    border-radius: 4px;
    background: #FAFAF7;
  }
  .choice .lbl {
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-right: auto;
  }
  .choice .opt {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-family: var(--sans);
    font-size: 11pt;
    color: var(--ink);
  }
  .choice .opt .box {
    width: 16px; height: 16px;
    border: 1.5px solid var(--ink);
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
    position: relative;
    transition: background 0.12s, border-color 0.12s;
  }
  .choice .opt.checked .box {
    background: var(--ink);
    border-color: var(--ink);
  }
  .choice .opt.checked .box::after {
    content: "";
    position: absolute;
    left: 3px; top: 1px;
    width: 5px; height: 9px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
  }
  .choice .opt.checked {
    font-weight: 600;
  }

  /* Pricing table */
  .price-card {
    border: 1px solid var(--hairline);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
  }
  .price-card .price-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 11px 18px;
    background: #FAFAF7;
    border-bottom: 1px solid var(--hairline);
  }
  .price-card .price-head .title {
    font-family: var(--serif);
    font-size: 17px;
    color: var(--ink);
  }
  .price-card .price-head .term {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
  }
  table.pricing {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--sans);
  }
  table.pricing th,
  table.pricing td {
    padding: 8px 16px;
    text-align: left;
    border-bottom: 1px solid var(--hairline-2);
    font-size: 10pt;
    color: var(--ink-2);
    vertical-align: top;
  }
  table.pricing th {
    font-family: var(--mono);
    font-size: 9.5px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    padding-top: 11px;
    padding-bottom: 9px;
    background: #FFFFFF;
    border-bottom: 1px solid var(--hairline);
  }
  table.pricing td.amount,
  table.pricing th.amount {
    text-align: right;
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    font-size: 10pt;
    color: var(--ink);
    white-space: nowrap;
    padding-right: 6px;
    width: 1%;
  }
  table.pricing td.unit,
  table.pricing th.unit {
    text-align: left;
    font-family: var(--mono);
    font-size: 9.5pt;
    color: var(--muted);
    white-space: nowrap;
    padding-left: 0;
    width: 80px;
  }
  table.pricing th.amount { padding-right: 6px; }
  table.pricing th.unit { padding-left: 0; }
  table.pricing tr:last-child td { border-bottom: 0; }
  table.pricing .desc { color: var(--muted); font-size: 9pt; margin-top: 2px; line-height: 1.42; }
  table.pricing tr.total td {
    border-top: 1.5px solid var(--ink);
    border-bottom: 0;
    padding-top: 11px;
    padding-bottom: 11px;
    background: #FAFAF7;
    font-weight: 600;
    color: var(--ink);
    font-size: 10.5pt;
  }

  /* Formula display — for Article Dépassement */
  .formula {
    margin: 8px 0 6px;
    padding: 16px 20px;
    border: 1px solid var(--hairline);
    border-radius: 4px;
    background: #FAFAF7;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .formula .f-eq {
    font-family: var(--serif);
    font-size: 24px;
    line-height: 1.1;
    color: var(--ink);
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
  }
  .formula .f-eq .op { color: var(--muted); font-style: italic; }
  .formula .f-eq .term {
    background: var(--paper);
    border: 1px solid var(--hairline);
    border-radius: 3px;
    padding: 4px 10px;
    font-size: 14px;
    font-family: var(--sans);
    font-weight: 500;
    color: var(--ink);
    line-height: 1.2;
  }
  .formula .f-eq .term.accent {
    border-color: transparent;
    background:
      linear-gradient(var(--paper), var(--paper)) padding-box,
      var(--brand-grad) border-box;
    border: 1px solid transparent;
  }
  .formula .f-note {
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.04em;
    color: var(--muted);
    line-height: 1.45;
  }

  /* Callout */
  .callout {
    background: var(--accent-soft);
    padding: 10px 16px 10px 18px;
    border-radius: 4px;
    position: relative;
    margin: 6px 0 4px;
    border: 1px solid var(--hairline);
  }
  .callout::before {
    content: "";
    position: absolute;
    left: 0; top: 10px; bottom: 10px;
    width: 2.5px;
    background: var(--brand-grad-v);
    border-radius: 2px;
  }
  .callout .label {
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink);
    margin-bottom: 4px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }
  .callout .label::before {
    content: "";
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--brand-grad);
  }
  .callout p { margin: 0; color: var(--ink); font-size: 10pt; line-height: 1.48; }

  /* Signature */
  .sig-band {
    margin-top: 4px;
    padding-top: 16px;
    border-top: 1.5px solid var(--ink);
    position: relative;
  }
  .sig-band::before {
    content: "";
    position: absolute;
    top: -1.5px; left: 0;
    width: 80px; height: 1.5px;
    background: var(--brand-grad);
  }
  .sig-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 26px;
    margin-top: 18px;
  }
  .sig-card {
    border: 1px solid var(--hairline);
    border-radius: 4px;
    padding: 16px 18px 20px;
    background: #FFFFFF;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }
  .sig-card .party-tag {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }
  .sig-card .party-tag .who {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .sig-card .party-tag .org {
    font-family: var(--serif);
    font-size: 16px;
    color: var(--ink);
  }
  .sig-field { display: flex; flex-direction: column; gap: 6px; }
  .sig-field .lbl {
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .sig-line {
    border-bottom: 1px solid var(--ink);
    height: 38px;
    display: flex;
    align-items: flex-end;
    padding-bottom: 4px;
    font-family: var(--serif);
    font-style: italic;
    font-size: 22px;
    color: var(--ink);
  }
  .sig-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .sig-meta { display: flex; flex-direction: column; gap: 2px; }
  .sig-meta .v {
    font-family: var(--sans);
    font-size: 12px;
    color: var(--ink);
    border-bottom: 1px solid var(--hairline);
    padding: 4px 0 6px;
    min-height: 26px;
  }

  /* Page footer */
  .page-footer {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--hairline);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .page-footer .conf { display: inline-flex; align-items: center; gap: 8px; }
  .page-footer .conf::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--brand-grad);
  }

  /* PRINT */
  @page { size: A4; margin: 0; }
  @media print {
    body { background: #fff; }
    .doc { gap: 0; padding: 0; }
    /* One .sheet = exactly one A4 page. Headers, footers and the hardcoded
       page counters depend on this 1:1 mapping — do not switch to auto height.
       Overflow is guarded at runtime by checkSheetOverflow(). */
    .sheet {
      width: 210mm;
      height: 297mm;
      min-height: 297mm;
      box-shadow: none;
      page-break-after: always;
      break-after: page;
    }
    .sheet:last-of-type { page-break-after: auto; break-after: auto; }
    /* Safety net: if a sheet ever does overflow, push whole blocks rather
       than slicing an article, a price table or a signature row in half. */
    article.section,
    .price-card,
    .choice,
    .section-header,
    .page-frame,
    .page-footer {
      break-inside: avoid;
      page-break-inside: avoid;
    }
    .sheet-overflow-warning { display: none !important; }
    .sheet.sheet-overflowing { outline: none !important; }
    .tweaks { display: none !important; }
  }

  /* Overflow guard — screen only */
  .sheet.sheet-overflowing { outline: 2px solid #C0392B; outline-offset: -2px; }
  .sheet-overflow-warning {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    background: #C0392B;
    color: #fff;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 6px 10px;
    text-align: center;
    z-index: 5;
  }

  /* =========================================================
     RESPONSIVE — MOBILE
     ========================================================= */
  @media (max-width: 700px) {
    .doc { padding: 12px 0 80px; gap: 12px; }

    .sheet {
      width: 100%;
      min-height: unset;
      padding: 16px 16px 24px;
      border-radius: 0;
      box-shadow: none;
    }

    /* Page header — simplify on mobile */
    .page-frame { flex-wrap: wrap; gap: 6px; padding-bottom: 8px; }
    .brand-mark .sep,
    .brand-mark .sub { display: none; }
    .brand-mark img.logo { height: 16px; }
    .page-frame .meta { font-size: 8px; line-height: 1.4; }

    /* Cover */
    .cover .page-frame { justify-content: flex-end; }
    .cover-stack { margin-top: 20px; }
    .cover-title { gap: 10px; margin-top: 12px; }
    .cover-title img { width: 160px !important; }
    .display-xl { font-size: 42px; }
    .display-l  { font-size: 26px; }
    .cover-subtitle { font-size: 11px; }

    .cover-grid { grid-template-columns: 1fr 1fr; }
    .cover-grid .cell:nth-child(4n) { border-right: 1px solid var(--hairline); padding-right: 12px; }
    .cover-grid .cell:nth-child(2n) { border-right: 0; padding-right: 0; }
    .cover-footer { flex-direction: column; align-items: flex-start; gap: 8px; }

    /* Parties — stack role above party */
    .parties { grid-template-columns: 1fr; column-gap: 0; }
    .parties .role-cell { padding: 10px 0 2px; border-bottom: 0; }
    .parties .party { padding: 0 0 12px; }
    .party-name { font-size: 17px; }

    /* Body sections */
    .section { grid-template-columns: 28px minmax(0, 1fr); column-gap: 8px; }
    .section.compact { grid-template-columns: 24px minmax(0, 1fr); column-gap: 6px; }
    .section-title { font-size: 16px; }
    .section.compact .section-title { font-size: 13px; }

    /* Pricing table — horizontal scroll on mobile */
    .price-card { overflow-x: auto; overflow-y: hidden; border-radius: 4px; }
    table.pricing th,
    table.pricing td { padding: 7px 10px; font-size: 8.5pt; }
    table.pricing td.num,
    table.pricing th.num { white-space: nowrap; }
    .price-card .price-head { flex-wrap: wrap; gap: 4px; padding: 9px 12px; }
    .price-card .price-head .title { font-size: 14px; }
    .price-card .price-head .term { font-size: 9px; }

    /* Formula */
    .formula { padding: 12px 14px; }
    .formula .f-eq { font-size: 16px; gap: 6px; }

    /* Sig grid */
    .sig-grid { grid-template-columns: 1fr; gap: 14px; }
    .sig-row  { grid-template-columns: 1fr 1fr; }

    /* Form trigger — bottom-right, small */
    .contract-form { width: 100%; }
    .form-trigger {
      top: unset !important;
      bottom: 16px !important;
      right: 16px;
      padding: 8px 13px;
      font-size: 9px;
      gap: 6px;
      letter-spacing: 0.10em;
      box-shadow: 0 8px 24px -8px rgba(20,20,20,0.5);
    }
    .form-trigger::before { width: 5px; height: 5px; }
  }

  /* Tweaks panel */
  .tweaks {
    position: fixed; right: 16px; bottom: 16px;
    width: 240px;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(10px);
    border: 1px solid var(--hairline);
    border-radius: 10px;
    box-shadow: 0 14px 40px -20px rgba(20,20,20,0.4), 0 2px 6px -2px rgba(20,20,20,0.1);
    font-family: var(--sans); font-size: 12px; color: var(--ink);
    z-index: 1000; overflow: hidden;
  }
  .tweaks header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; border-bottom: 1px solid var(--hairline);
    background: #FAFAF7;
  }
  .tweaks header .title {
    font-family: var(--mono); font-size: 10px;
    letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
  }
  .tweaks header button {
    background: none; border: 0; cursor: pointer; color: var(--muted);
    font-size: 16px; line-height: 1; padding: 4px;
  }
  .tweaks .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 14px; }
  .tweaks .row { display: flex; flex-direction: column; gap: 6px; }
  .tweaks .lbl {
    font-family: var(--mono); font-size: 9.5px;
    letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
  }
  .tweaks .seg {
    display: flex; border: 1px solid var(--hairline);
    border-radius: 6px; overflow: hidden;
  }
  .tweaks .seg button {
    flex: 1; background: #fff; border: 0; cursor: pointer;
    padding: 7px 8px; font-family: var(--sans); font-size: 11px; color: var(--muted);
    border-right: 1px solid var(--hairline);
  }
  .tweaks .seg button:last-child { border-right: 0; }
  .tweaks .seg button.active { background: var(--ink); color: #fff; }

  /* =========================================================
     Contract data form — fill placeholders live
     ========================================================= */
  .form-trigger {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1001;
    padding: 10px 14px 10px 12px;
    border-radius: 999px;
    background: var(--ink);
    color: var(--paper);
    border: 0;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    box-shadow: 0 14px 32px -12px rgba(20,20,20,0.5), 0 2px 4px -1px rgba(0,0,0,0.1);
    transition: transform 0.18s, background 0.18s;
  }
  .form-trigger:hover { transform: translateY(-1px); }
  .form-trigger::before {
    content: "";
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--brand-grad);
  }

  .contract-form {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 360px;
    background: var(--paper);
    border-left: 1px solid var(--hairline);
    box-shadow: -14px 0 40px -22px rgba(0,0,0,0.25);
    z-index: 1002;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.36s cubic-bezier(0.2, 0.7, 0.2, 1);
    font-family: var(--sans);
    color: var(--ink);
  }
  .contract-form.open { transform: translateX(0); }
  .contract-form::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--brand-grad);
  }
  .contract-form > header {
    padding: 28px 24px 18px;
    border-bottom: 1px solid var(--hairline);
    position: relative;
  }
  .contract-form > header .eyebrow {
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .contract-form > header h3 {
    font-family: var(--serif);
    font-size: 30px;
    line-height: 1.05;
    margin: 6px 0 0;
    font-weight: 400;
    letter-spacing: -0.015em;
    color: var(--ink);
  }
  .contract-form > header p.intro {
    font-size: 12px;
    color: var(--muted);
    margin: 8px 0 0;
    line-height: 1.5;
  }
  .form-close-btn {
    position: absolute;
    top: 18px;
    right: 18px;
    background: none;
    border: 0;
    cursor: pointer;
    color: var(--muted);
    font-size: 22px;
    padding: 4px;
    line-height: 1;
  }
  .form-close-btn:hover { color: var(--ink); }

  .form-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .form-section-title {
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink);
    padding: 14px 0 6px;
    border-bottom: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .form-section-title::before {
    content: "";
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--brand-grad);
  }
  .form-section-title:first-child { padding-top: 4px; }

  .form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  .form-group label {
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 500;
    color: var(--ink);
  }
  .form-group .hint {
    font-family: var(--sans);
    font-size: 10px;
    color: var(--muted);
    font-weight: 400;
    margin-top: -2px;
    line-height: 1.4;
  }
  .form-group input {
    font-family: var(--sans);
    font-size: 13px;
    padding: 9px 12px;
    border: 1px solid var(--hairline);
    border-radius: 4px;
    background: var(--paper);
    color: var(--ink);
    outline: 0;
    width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  }
  .form-group input::placeholder {
    color: var(--muted-2);
    font-style: italic;
  }
  .form-group input:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(199, 62, 126, 0.10);
  }
  .form-group input[type="date"] {
    font-family: var(--mono);
    font-size: 12px;
  }

  .form-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
  }
  .form-progress .pt {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
  }
  .form-progress .bar {
    flex: 1;
    height: 3px;
    background: var(--hairline);
    border-radius: 3px;
    overflow: hidden;
  }
  .form-progress .fill {
    height: 100%;
    background: var(--brand-grad);
    transition: width 0.3s ease;
    width: 0%;
  }

  .form-footer {
    border-top: 1px solid var(--hairline);
    padding: 14px 20px 18px;
    background: #FAFAF7;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .form-footer .btn {
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 13px 18px;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.15s, background 0.15s;
  }
  .form-footer .btn-primary {
    background: var(--ink);
    color: var(--paper);
  }
  .form-footer .btn-primary:hover { transform: translateY(-1px); }
  .form-footer .btn-primary::after { content: "→"; font-size: 14px; }
  .form-footer .btn-secondary {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--hairline);
  }
  .form-footer .btn-secondary:hover { color: var(--ink); }

  /* Placeholder filled state — render value as normal text */
  .ph.filled {
    background: none;
    font-family: inherit;
    font-size: inherit;
    letter-spacing: inherit;
    padding: 0;
    color: inherit;
  }

  @media print {
    .form-trigger, .contract-form, #login-overlay { display: none !important; }
  }

  /* Login overlay */
  /* Abonnement type toggle */
  .type-toggle {
    display: flex;
    gap: 0;
    border: 1px solid var(--hairline);
    border-radius: 4px;
    overflow: hidden;
  }
  .type-btn {
    flex: 1;
    padding: 8px 12px;
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    border: none;
    background: #FAFAF7;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
  }
  .type-btn + .type-btn { border-left: 1px solid var(--hairline); }
  .type-btn.active {
    background: var(--ink);
    color: #fff;
  }

  /* Inactive subscription row in recap table */
  tr.row-inactive td {
    opacity: 0.35;
    text-decoration: line-through;
    text-decoration-color: var(--muted);
  }

  /* Login overlay */
  #login-overlay {
    position: fixed;
    inset: 0;
    background: #F5F4F0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.35s ease;
  }
  #login-overlay.hidden {
    opacity: 0;
    pointer-events: none;
  }
  #login-card {
    background: #fff;
    border: 1px solid var(--hairline);
    border-radius: 8px;
    padding: 40px 36px 36px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 40px -12px rgba(20,20,20,0.18);
  }
  #login-logo {
    width: 160px;
    height: auto;
    display: block;
    margin-bottom: 20px;
  }
  #login-subtitle {
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 28px;
  }
  .login-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
  }
  .login-field label {
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .login-field input {
    font-family: var(--sans);
    font-size: 14px;
    color: var(--ink);
    background: #FAFAF7;
    border: 1px solid var(--hairline);
    border-radius: 4px;
    padding: 9px 12px;
    outline: none;
    transition: border-color 0.15s;
  }
  .login-field input:focus {
    border-color: #0A0A0A;
    background: #fff;
  }
  #login-error {
    font-family: var(--sans);
    font-size: 12px;
    color: #C0392B;
    min-height: 18px;
    margin-bottom: 8px;
  }
  #login-btn {
    width: 100%;
    background: var(--ink);
    color: #fff;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    border: none;
    border-radius: 4px;
    padding: 13px 20px;
    cursor: pointer;
    transition: opacity 0.15s;
    margin-top: 4px;
  }
  #login-btn:hover { opacity: 0.82; }

  /* ---- Clause editor ---- */
  .clause-add-btn {
    width: 100%;
    background: transparent;
    border: 1px dashed var(--hairline);
    border-radius: 4px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 9px;
    cursor: pointer;
    margin-bottom: 12px;
    transition: border-color 0.15s, color 0.15s;
  }
  .clause-add-btn:hover { border-color: var(--ink); color: var(--ink); }
  .clause-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--hairline-2);
    font-family: var(--sans);
    font-size: 12px;
    color: var(--ink-2);
  }
  .clause-item .clause-num {
    font-family: var(--mono);
    font-size: 9px;
    color: var(--muted);
    min-width: 28px;
  }
  .clause-item .clause-title-text { flex: 1; }
  .clause-item-btns { display: flex; gap: 4px; }
  .clause-item-btns button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    color: var(--muted);
    padding: 2px 4px;
  }
  .clause-item-btns button:hover { color: var(--ink); }
  #clause-editor {
    background: #FAFAF7;
    border: 1px solid var(--hairline);
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 12px;
  }
  #clause-editor textarea {
    width: 100%;
    box-sizing: border-box;
    font-family: var(--sans);
    font-size: 13px;
    border: 1px solid var(--hairline);
    border-radius: 4px;
    padding: 8px;
    resize: vertical;
    background: #fff;
  }
  #btn-clause-save {
    background: var(--ink);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 9px;
    cursor: pointer;
  }
  #btn-clause-cancel {
    background: none;
    border: 1px solid var(--hairline);
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 9px;
    cursor: pointer;
    color: var(--muted);
  }
  /* Custom clause in the contract */
  article.custom-clause { border-top: 1px dashed var(--hairline); }

  /* ---- Inline editing ---- */
  .section { position: relative; }
  .art-action-bar {
    position: absolute; top: 2px; right: 0;
    display: flex; gap: 4px; align-items: center;
    opacity: 0; transition: opacity 0.15s;
    z-index: 2;
  }
  .section:hover .art-action-bar { opacity: 1; }
  .section.art-editing .art-action-bar { display: none; }
  .art-edit-btn, .art-del-btn {
    background: #fff; border: 1px solid var(--hairline-2);
    border-radius: 4px; padding: 2px 9px;
    font-size: 10px; cursor: pointer; color: var(--muted);
    font-family: var(--mono); letter-spacing: 0.08em;
  }
  .art-del-btn:hover { color: #c0392b; border-color: #c0392b; }
  /* contentEditable field styling */
  .art-editing [contenteditable="true"] {
    outline: none;
    background: #FAFAF7;
    border-radius: 3px;
    box-shadow: 0 0 0 2px var(--hairline);
    padding: 2px 4px;
    cursor: text;
  }
  .art-editing .section-title[contenteditable="true"] {
    display: block;
    padding: 3px 6px;
  }
  /* Save bar shown at bottom of edited article */
  .art-edit-save-bar {
    display: flex; gap: 8px; margin-top: 14px; padding-top: 12px;
    border-top: 1px solid var(--hairline-2);
  }
  .art-inline-save {
    background: var(--ink); color: #fff; border: none; border-radius: 4px;
    font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em;
    text-transform: uppercase; padding: 8px 16px; cursor: pointer; flex: 1;
  }
  .art-inline-cancel {
    background: none; border: 1px solid var(--hairline); border-radius: 4px;
    font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em;
    text-transform: uppercase; padding: 8px 14px; cursor: pointer; color: var(--muted);
  }
  /* "+" add-clause spacer between articles */
  .art-add-row {
    display: flex; justify-content: center; align-items: center;
    height: 20px; opacity: 0; transition: opacity 0.15s;
  }
  .body:hover .art-add-row { opacity: 1; }
  .art-add-btn {
    background: none; border: 1px dashed var(--hairline-2); border-radius: 20px;
    font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em;
    padding: 2px 14px; cursor: pointer; color: var(--muted);
    text-transform: uppercase;
  }
  .art-add-btn:hover { border-color: var(--accent); color: var(--accent); }
  /* New clause inline form (standalone article) */
  article.art-new-inline {
    background: #FAFAF7; border: 1px solid var(--hairline);
    border-radius: 6px; padding: 14px; grid-column: 1 / -1;
  }
  article.art-new-inline label {
    display: block; font-family: var(--mono); font-size: 9px;
    letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--muted); margin-bottom: 4px; margin-top: 10px;
  }
  article.art-new-inline label:first-child { margin-top: 0; }
  article.art-new-inline input, article.art-new-inline textarea {
    width: 100%; box-sizing: border-box;
    font-family: var(--sans); font-size: 13px;
    border: 1px solid var(--hairline); border-radius: 4px;
    padding: 7px 9px; background: #fff;
  }
  article.art-new-inline textarea { resize: vertical; min-height: 80px; }
  article.art-new-inline .art-inline-save-bar { display: flex; gap: 8px; margin-top: 12px; }
  @media print {
    .art-edit-btn, .art-add-row, .art-inline-edit,
    article.art-new-inline { display: none !important; }
  }
  /* Applied only while checkSheetOverflow() measures, so on-screen heights
     match the printed layout. Must mirror the @media print rule above —
     .art-add-row alone adds ~20px per article and would fake an overflow. */
  .measuring-print .art-edit-btn,
  .measuring-print .art-add-row,
  .measuring-print .art-inline-edit,
  .measuring-print article.art-new-inline { display: none !important; }

  /* ---- Back to contract picker (screen only) ---- */
  .home-link {
    position: fixed;
    top: 18px; left: 18px;
    z-index: 900;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 13px;
    background: var(--paper);
    border: 1px solid var(--hairline);
    border-radius: 999px;
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    text-decoration: none;
    box-shadow: 0 2px 8px -4px rgba(20,20,20,0.25);
    transition: color 0.15s, border-color 0.15s, transform 0.15s;
  }
  .home-link:hover {
    color: var(--ink);
    border-color: var(--muted-2);
    transform: translateX(-2px);
  }
  @media print { .home-link { display: none !important; } }
  @media (max-width: 700px) {
    .home-link { top: 10px; left: 10px; padding: 6px 10px; font-size: 9px; }
  }
