  :root {
    --ink: #10021c;          /* logo navy */
    --line: #9a93a0;
    --line-strong: #5b4f63;
    --muted: #6b6275;
    --brand: #ff541f;        /* logo orange */
    --brand-dark: #10021c;   /* logo navy */
    --accent: #5b2a86;       /* logo purple (SEIU) */
    --shade: #fbf2ee;        /* warm tint */
    --shade-bar: #fbe1d6;    /* light orange tint */
    --err: #c0392b;
    --ok: #1f8a4c;
    /* form surfaces (themeable) */
    --paper: #ffffff;        /* the sheet */
    --paper-2: #fcfdff;      /* boxed inputs */
    --focus-bg: #fff3ef;     /* line input focus */
    --comb-focus: #ffe7dd;   /* comb focus */
    --logo-plate: transparent;

    /* Drawbridge theme — drives the page background + the toolbar buttons */
    --db-bg: #F4F1F0;          /* Background 2  */
    --db-surface: #E9E3E2;     /* Foreground    */
    --db-emphasis: #D8CDCB;    /* Emphasis      */
    --db-text: #444241;        /* Text primary  */
    --db-accent: #ED1459;      /* Accent        */
    --db-accent-hover: #cc0f4c;
    --db-accent-text: #FFFFFF; /* Accent text   */
    --wm-opacity: .06;         /* background watermark */
    --db-bar: rgba(255,255,255,.62);   /* frosted header */
    --db-bar-border: rgba(0,0,0,.10);
  }
  html[data-theme="dark"] {
    /* form goes dark too (screen only — print is forced light below) */
    --ink: #e7edf2;
    --line: #55626c;
    --line-strong: #8497a3;
    --muted: #9fb0bd;
    --brand-dark: #f2ebe8;   /* headings readable on dark */
    --shade: #222d35;
    --shade-bar: #2c3a44;
    --paper: #1f272e;
    --paper-2: #283139;
    --focus-bg: #2c3942;
    --comb-focus: #38474f;
    --logo-plate: #ffffff;   /* white chip keeps the logo legible */

    --db-bg: #1D2830;          /* Background    */
    --db-surface: #273845;     /* Foreground    */
    --db-emphasis: #3D576A;    /* Emphasis      */
    --db-text: #F5F5F5;        /* Text primary  */
    --db-accent: #ED1459;      /* Accent        */
    --db-accent-hover: #ff2e6e;
    --db-accent-text: #FFFFFF; /* Accent text   */
    --wm-opacity: .10;
    --db-bar: rgba(22,29,34,.58);      /* frosted header */
    --db-bar-border: rgba(255,255,255,.10);
  }
  * { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  body {
    font-family: "Segoe UI", Roboto, Arial, Helvetica, sans-serif;
    color: var(--ink);
    font-size: 19.44px;
    line-height: 1.28;
    margin: 0;
    min-height: 100vh;
    background: var(--db-bg);
    transition: background .2s ease;
  }
  .page {
    background: var(--paper);
    color: var(--ink);
    width: 340.2mm;            /* A4 */
    min-height: 481.14mm;       /* A4 */
    margin: 29.16px auto;
    padding: 16.2mm 21.06mm;
    box-shadow: 0 6.48px 29.16px rgba(0,0,0,.22);
    border-radius: 3.24px;
    position: relative;
    z-index: 1;
    transition: background .2s ease, color .2s ease;
  }

  /* Header */
  header {
    display: flex;
    align-items: center;
    gap: 19.44px;
    border-bottom: 4.86px solid var(--brand);
    padding-bottom: 9.72px;
    margin-bottom: 4.86px;
    position: relative;
  }
  header .logo { height: 74.52px; width: auto; flex: 0 0 auto; background: var(--logo-plate); padding: 0; border-radius: 6.48px; transition: background .2s, padding .2s; }
  html[data-theme="dark"] header .logo { padding: 4.86px 8.1px; }
  header .head-titles { flex: 1 1 auto; text-align: center; }
  header .org { font-weight: 800; font-size: 21.06px; color: var(--brand-dark); letter-spacing: 0.324px; }
  header .title { font-weight: 700; font-size: 19.44px; margin-top: 3.24px; color: var(--ink); }
  header .regno {
    display: inline-block;
    font-size: 16.2px; margin-top: 6.48px; letter-spacing: 1.62px;
    background: var(--shade-bar); color: var(--brand-dark);
    padding: 3.24px 16.2px; border-radius: 16.2px; font-weight: 700;
  }

  /* Section bars */
  .section {
    background: linear-gradient(to bottom, var(--shade-bar), var(--shade));
    border: 1.62px solid var(--line);
    border-left: 6.48px solid var(--brand);
    padding: 4.86px 12.96px;
    margin: 11.34px 0 6.48px;
    font-size: 17.82px;
    border-radius: 4.86px;
  }
  .section b { font-size: 18.63px; color: var(--brand-dark); }
  .section .hint { font-weight: 400; font-style: italic; color: var(--muted); }

  /* Beneficiary bar with inline Remove / Add controls (screen-only buttons) */
  .section.benef-bar { display: flex; align-items: center; gap: 9.72px; }
  .section.benef-bar > b { flex: 1 1 auto; }
  .remove-benef, .add-benef {
    flex: 0 0 auto; font: inherit; font-size: 13.77px; line-height: 1;
    padding: 4.86px 11.34px; border-radius: 4.86px; cursor: pointer; white-space: nowrap;
  }
  .remove-benef { background: var(--paper); border: 1.62px solid var(--line); color: var(--muted); }
  .remove-benef:hover { border-color: var(--err); color: var(--err); }
  .add-benef { background: var(--brand); border: 1.62px solid var(--brand); color: #fff; font-weight: 700; }
  .add-benef:hover { filter: brightness(1.08); }

  /* Field rows */
  .row { display: flex; gap: 25.92px; align-items: flex-end; margin: 8.1px 0; flex-wrap: wrap; }
  .field { display: flex; flex-direction: column; flex: 1; min-width: 194.4px; }
  .field.grow2 { flex: 2; }
  .field label, .caption {
    font-size: 13.77px;
    color: var(--muted);
    margin: 4px 0 0;
    order: 2;             /* caption BELOW the control */
    text-transform: uppercase;
    letter-spacing: 0.486px;
  }
  input.line {
    border: none;
    border-bottom: 2.43px solid var(--line);
    height: 32.4px;
    font-size: 19.44px;
    padding: 0 4.86px;
    background: transparent;
    color: var(--ink);
    width: 100%;
    order: 1;
    transition: border-color .15s, background .15s;
  }
  input.line:hover { border-bottom-color: var(--line-strong); }
  input.line:focus {
    outline: none;
    border-bottom: 3.24px solid var(--brand);
    background: var(--focus-bg);
  }

  /* Relationship dropdown — native <select> styled to match the line inputs */
  select.rel-select {
    border: none;
    border-bottom: 2.43px solid var(--line);
    height: 32.4px;
    font-size: 19.44px;
    padding: 0 27px 0 4.86px;
    background-color: transparent;
    color: var(--ink);
    width: 100%;
    order: 1;
    -webkit-appearance: none; appearance: none;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23888' stroke-width='2'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 5px center;
  }
  select.rel-select:hover { border-bottom-color: var(--line-strong); }
  select.rel-select:focus {
    outline: none;
    border-bottom: 3.24px solid var(--brand);
    background-color: var(--focus-bg);
  }
  select.rel-select option { color: #444241; }   /* readable in the OS dropdown popup */

  /* Province dropdown — custom, themeable, matches the line inputs */
  .select { position: relative; width: 100%; order: 1; }
  /* size the Province field to just fit the longest name (no excess empty space) */
  .field:has(> .select.province) { flex: 0 0 auto; width: 272.16px; min-width: 272.16px; }
  .select-trigger {
    width: 100%; height: 32.4px;
    display: flex; align-items: center;
    text-align: left; font: inherit; font-size: 18.63px; color: var(--ink);
    background: transparent;
    border: none; border-bottom: 2.43px solid var(--line);
    padding: 0 25.92px 0 4.86px; margin: 0; cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: border-color .15s, background .15s;
  }
  .select-trigger::after {
    content: ""; position: absolute; right: 6.48px; top: 50%;
    width: 9.72px; height: 9.72px; margin-top: -8.1px;
    border-right: 2.43px solid var(--muted); border-bottom: 2.43px solid var(--muted);
    transform: rotate(45deg); transition: transform .15s;
  }
  .select.open .select-trigger::after { transform: rotate(225deg); margin-top: -3.24px; }
  .select-trigger:hover { border-bottom-color: var(--line-strong); }
  .select.open .select-trigger,
  .select-trigger:focus { outline: none; border-bottom: 3.24px solid var(--brand); background: var(--focus-bg); }

  .select-menu {
    position: absolute; z-index: 40; top: calc(100% + 4.86px); left: 0; right: auto;
    min-width: 100%; width: max-content; max-width: 486px;
    margin: 0; padding: 6.48px; list-style: none;
    max-height: 388.8px; overflow-y: auto;
    background: var(--paper); color: var(--ink);
    border: 1.62px solid var(--line); border-radius: 9.72px;
    box-shadow: 0 12.96px 35.64px rgba(0,0,0,.28);
    display: none;
  }
  .select.open .select-menu { display: block; }
  .select-menu li {
    padding: 9.72px 14.58px; font-size: 19.44px; line-height: 1.2;
    border-radius: 6.48px; cursor: pointer; white-space: nowrap;
  }
  .select-menu li.active { background: var(--shade-bar); }
  .select-menu li[aria-selected="true"] { font-weight: 700; color: var(--brand-dark); }

  /* === EXPERIMENT3: geographic map + leader tiles for the Maritimes === */
  .select-menu.is-geomap { width: auto; max-width: none; max-height: none; padding: 16.2px; overflow: hidden; }
  .geo-inner { position: relative; display: flex; align-items: stretch; gap: 19.44px; }
  .geo-wrap { width: 375.84px; flex: 0 0 auto; }
  .ca-geomap { width: 375.84px; height: auto; display: block; }
  .ca-geomap path {
    fill: var(--paper-2); stroke: var(--line); stroke-width: 0.7;
    cursor: pointer; transition: fill .12s;
  }
  .ca-geomap path:hover, .ca-geomap path.hot { fill: var(--shade-bar); }
  .ca-geomap path[aria-selected="true"] { fill: var(--brand); }

  .geo-leaders { flex: 0 0 auto; width: 223.56px; display: flex; flex-direction: column; justify-content: flex-end; gap: 9.72px; }
  .geo-leaders-title { font-size: 14.58px; text-transform: uppercase; letter-spacing: 0.81px; color: var(--muted); margin-bottom: 1.62px; }
  .leader-tile {
    display: flex; flex-direction: column; align-items: flex-start;
    border: 1.62px solid var(--line); border-radius: 8.1px; background: var(--paper-2);
    color: var(--ink); cursor: pointer; padding: 6.48px 12.96px; text-align: left;
    font-weight: 700; font-size: 17.82px; line-height: 1.2; transition: background .12s, border-color .12s;
  }
  .leader-tile small { font-weight: 400; font-size: 13.77px; color: var(--muted); }
  .leader-tile:hover, .leader-tile:focus { outline: none; background: var(--shade-bar); border-color: var(--brand); }
  .leader-tile[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
  .leader-tile[aria-selected="true"] small { color: rgba(255,255,255,.85); }

  .geo-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; overflow: visible; }
  .geo-lines line { stroke: var(--brand); stroke-width: 1.4; }
  .geo-lines circle { fill: var(--brand); }

  .select-menu.is-geomap .ca-caption {
    margin-top: 12.96px; min-height: 27.54px; text-align: center;
    font-size: 19.44px; font-weight: 700; color: var(--brand-dark);
  }
  .select-menu.is-geomap .ca-caption .hint { font-weight: 400; font-style: italic; color: var(--muted); font-size: 17.82px; }

  /* Comb / boxed character inputs */
  .comb { display: inline-flex; }
  .comb input {
    width: 30.78px; height: 34.02px;
    border: 1.62px solid var(--line);
    border-left: none;
    text-align: center;
    font-size: 21.06px;
    padding: 0;
    color: var(--ink);
    background: var(--paper-2);
    transition: background .12s, box-shadow .12s;
  }
  .comb input:first-child,
  .comb .sep + input { border-left: 1.62px solid var(--line); border-radius: 4.86px 0 0 4.86px; }
  .comb input:last-child,
  .comb input:has(+ .sep) { border-radius: 0 4.86px 4.86px 0; }
  .comb input:focus {
    outline: none;
    background: var(--comb-focus);
    box-shadow: inset 0 0 0 2.43px var(--brand);
    position: relative; z-index: 1;
  }
  .comb input.filled { background: var(--paper); }
  .comb .sep { display: inline-flex; align-items: center; padding: 0 6.48px; color: var(--muted); font-weight: 700; }
  .comb-labels { display: grid; grid-template-columns: repeat(8, 30.78px); font-size: 12.96px; color: var(--muted); margin-top: 1.62px; }
  .comb-labels span { text-align: center; }
  .comb-labels span:nth-child(1) { grid-column: 1 / 3; }   /* DD  — over boxes 1-2  */
  .comb-labels span:nth-child(2) { grid-column: 3 / 5; }   /* MM  — over boxes 3-4  */
  .comb-labels span:nth-child(3) { grid-column: 5 / 9; }   /* YYYY — over boxes 5-8 */
  .inline { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; flex: 1 1 0; min-width: 194.4px; }
  .inline > .lbl { order: 2; }                 /* caption under the comb, like other fields */
  .field-block .comb-labels { order: -1; }      /* D D / M M / Y Y Y Y above the date boxes */
  /* unify all field/group labels with the bottom captions: uppercase, muted, small, spaced */
  .lbl { font-size: 13.77px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.486px; }
  .field-block { display: inline-flex; flex-direction: column; }
  .row.phones .inline { flex: 0 0 auto; }
  .row.phones .lang-cell { flex: 1 1 auto; }
  .email-cap { order: 2; display: flex; align-items: baseline; justify-content: space-between; gap: 24px; width: 100%; }
  .email-cap label { order: 0; margin: 0; }
  .email-cap .email-note { margin: 0; text-align: right; }
  .field:has(> .postal-comb) { flex: 0 0 auto; }   /* shrink to the boxes & sit right; caption's P aligns with the first box */

  .checks { display: flex; gap: 25.92px; align-items: center; flex-wrap: wrap; }
  .checks.col { flex-direction: column; align-items: flex-start; gap: 8px; }
  .radios { display: flex; gap: 21.6px; align-items: center; flex-wrap: wrap; }
  /* radio options as square check-boxes, matching the SIN/comb boxes (uniform) */
  #planForm .checks input[type="radio"], #planForm .radios input[type="radio"] {
    position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0;
  }
  #planForm .checks input[type="radio"] + label,
  #planForm .radios input[type="radio"] + label {
    display: inline-flex; align-items: center; gap: 9px; margin: 0; cursor: pointer;
    font-size: 16.2px; font-weight: 400; color: var(--ink);
  }
  #planForm input[type="radio"] + label::before {
    content: ""; width: 27px; height: 27px; flex: 0 0 auto;
    border: 1.62px solid var(--line); border-radius: 4px; background: var(--paper-2);
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: 18px; font-weight: 700; line-height: 1;
  }
  #planForm input[type="radio"]:checked + label::before { content: "✓"; background: var(--brand); border-color: var(--brand); }
  #planForm input[type="radio"] + label:hover::before { border-color: var(--brand); }
  #planForm input[type="radio"]:focus-visible + label::before { outline: 3px solid var(--accent); outline-offset: 2px; }
  .checks label { font-size: 17.82px; display: inline-flex; align-items: center; gap: 8.1px; cursor: pointer; }
  .checks input { width: 22.68px; height: 22.68px; accent-color: var(--brand); }

  .note { font-size: 15.39px; font-style: italic; color: var(--muted); margin: 3.24px 0; }
  .body-text { font-size: 16.2px; text-align: justify; margin: 4.86px 0; line-height: 1.2; }
  .body-text b { font-size: 16.2px; color: var(--brand-dark); }
  .callout {
    text-align: center; font-weight: 700; color: var(--brand-dark);
    background: var(--shade); border: 1.62px dashed var(--brand);
    padding: 6.48px; border-radius: 6.48px; margin: 8.1px 0;
  }

  /* Share of Benefit — highlighted box so it stands out */
  .share-box {
    display: inline-flex; align-items: center; gap: 12.96px;
    background: var(--shade-bar);
    border: 2.43px solid var(--brand);
    border-radius: 8.1px;
    padding: 3.24px 16.2px;
    box-shadow: 0 1.62px 8.1px rgba(255,84,31,.20);
  }
  .share-box .share-label {
    font-size: 16.2px; font-weight: 700; color: var(--brand-dark);
    text-transform: uppercase; letter-spacing: 0.648px;
  }
  .share-box .share-input-wrap { display: inline-flex; align-items: center; gap: 4.86px; }
  .share-box input.share {
    width: 81px; height: 37.26px; text-align: center;
    font-size: 21.06px; font-weight: 700; color: var(--brand-dark);
    border: 1.62px solid var(--brand); border-radius: 6.48px;
    background: var(--paper); padding: 0 6.48px;
  }
  .share-box input.share:focus { outline: none; box-shadow: 0 0 0 3.24px rgba(255,84,31,.40); }
  .share-box .pct { font-weight: 700; color: var(--brand-dark); font-size: 21.06px; }

  .footer-return { text-align: center; font-size: 17.01px; margin-top: 9.72px; padding: 9.72px; background: var(--shade); border-radius: 6.48px; }
  .footer-return .big { font-weight: 700; color: var(--brand-dark); }

  /* Definition of Spouse — each province in its own light box, uniform body font */
  .def-title { font-weight: 700; margin: 14px 0 6.48px; color: var(--brand-dark); font-size: 17.01px; }
  .def-box {
    background: var(--shade);
    border: 1.62px dashed var(--brand);
    border-radius: 6.48px;
    padding: 8.1px 14.58px;
    margin: 8.1px 0;
    font-size: 15.39px;
    line-height: 1.25;
  }
  .def-box h4 { margin: 0 0 3.24px; font-size: 15.39px; color: var(--brand-dark); }
  .def-box ol { margin: 1.62px 0 1.62px 29.16px; padding: 0; font-size: 15.39px; }
  .def-box ol ol { list-style: lower-roman; }

  /* ---------- validation feedback ---------- */
  /* the field itself signals the error */
  input.line.invalid { border-bottom: 3.24px solid var(--err); background: rgba(192,57,43,.07); }
  select.rel-select.invalid { border-bottom: 3.24px solid var(--err); background-color: rgba(192,57,43,.07); }
  .comb.invalid input { border-color: var(--err) !important; box-shadow: inset 0 0 0 1.62px var(--err); }
  .select.invalid .select-trigger { border-bottom: 3.24px solid var(--err); }
  .share-box.invalid { border-color: var(--err); box-shadow: 0 0 0 3.24px rgba(192,57,43,.30); }
  input[type="checkbox"].invalid { outline: 3.24px solid var(--err); outline-offset: 1.62px; }
  .radios.invalid { outline: 3.24px solid var(--err); outline-offset: 4px; border-radius: 4.86px; }
  .inline:has(> .radios.invalid) .lbl { color: var(--err); }
  .field:has(> .invalid) label { color: var(--err); }
  .field:has(> .invalid) label::after { content: " ⚠"; font-size: 14.58px; }

  /* teacher's-margin error marks: red notes in the gutters, arrows to each field */
  #marks { position: absolute; top: 0; left: 0; width: 100%; z-index: 60; pointer-events: none; }
  #marks svg { position: absolute; top: 0; left: 0; width: 100%; overflow: visible; }
  #marks .mark-label {
    position: absolute; max-width: 223.2px;
    color: var(--err); font-size: 20.25px; font-weight: 700; line-height: 1.25;
    font-family: "Bradley Hand", "Segoe Script", "Comic Sans MS", cursive;
    text-shadow: 0 0.9px 0 rgba(255,255,255,.6), 0 0 1.8px rgba(255,255,255,.5);
    pointer-events: auto; cursor: pointer;   /* clickable to dismiss (overlay itself ignores pointer events) */
  }
  #marks .mark-label:hover { opacity: .6; }
  #marks .mark-label.left  { transform: translate(-100%, -50%); text-align: right; padding-right: 7.2px; }
  #marks .mark-label.right { transform: translateY(-50%);        text-align: left;  padding-left: 7.2px; }
  /* when there's no gutter room (e.g. zoomed in), notes flip above/below the field as chips */
  #marks .mark-label.above, #marks .mark-label.below {
    text-align: center; max-width: 310.5px; background: var(--paper);
    padding: 3.6px 9px; border: 1.35px solid var(--err); border-radius: 6.3px;
    box-shadow: 0 2.7px 10.8px rgba(0,0,0,.22); text-shadow: none;
  }
  #marks .mark-label.above { transform: translate(-50%, -100%); }
  #marks .mark-label.below { transform: translate(-50%, 0); }
  html[data-theme="dark"] #marks .mark-label { text-shadow: 0 0.9px 1.8px rgba(0,0,0,.7); }
  html[data-theme="dark"] #marks .mark-label.above, html[data-theme="dark"] #marks .mark-label.below { text-shadow: none; }

  /* e-signature */
  .esign {
    margin-top: 9.72px;
    border: 1.62px solid var(--line);
    border-left: 6.48px solid var(--brand);
    border-radius: 6.48px;
    padding: 12.96px 19.44px;
    background: var(--shade);
  }
  .attest { display: flex; gap: 14.58px; align-items: flex-start; font-size: 17.82px; line-height: 1.45; cursor: pointer; }
  .attest input { width: 25.92px; height: 25.92px; margin-top: 1.62px; accent-color: var(--brand); flex: 0 0 auto; }
  input.sig {
    font-family: "Segoe Script", "Bradley Hand", "Brush Script MT", "Comic Sans MS", cursive;
    font-size: 35.64px;
    color: var(--brand-dark);
    height: 55.08px;
  }
  input.sig::placeholder { font-family: "Segoe UI", Arial, sans-serif; font-size: 19.44px; font-style: italic; color: var(--muted); }

  /* toolbar */
  .toolbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 90;
    display: flex; align-items: center; gap: 12.96px;
    padding: 8.1px 22.68px;
    background: var(--db-bar);
    -webkit-backdrop-filter: blur(19.44px) saturate(1.3);
    backdrop-filter: blur(19.44px) saturate(1.3);
    border-bottom: 1.62px solid var(--db-bar-border);
    box-shadow: 0 1.62px 16.2px rgba(0,0,0,.06);
  }
  .bottombar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 90;
    display: flex; align-items: center; justify-content: flex-end; gap: 12.96px;
    padding: 8.1px 22.68px;
    background: var(--db-bar);
    -webkit-backdrop-filter: blur(19.44px) saturate(1.3);
    backdrop-filter: blur(19.44px) saturate(1.3);
    border-top: 1.62px solid var(--db-bar-border);
    box-shadow: 0 -1.62px 16.2px rgba(0,0,0,.06);
  }
  .hdr-logo { height: 27.54px; width: auto; flex: 0 0 auto; margin-right: 3.24px; display: block; }
  .hdr-link { font-size: 17.82px; color: var(--db-text); text-decoration: underline; opacity: .8; white-space: nowrap; }
  .hdr-link:hover { opacity: 1; }
  .tool-div { width: 1.62px; height: 29.16px; background: var(--db-emphasis); opacity: .7; margin: 0 3.24px; }
  .icon-btn { text-decoration: none; }
  .icon-btn {
    width: 45.36px; height: 45.36px; padding: 0; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 11.34px; border: 1.62px solid var(--db-emphasis);
    background: var(--db-surface); color: var(--db-text);
    transition: background .15s, color .15s, border-color .15s, transform .08s;
  }
  .icon-btn svg { width: 24.3px; height: 24.3px; }
  .icon-btn:hover { background: var(--db-emphasis); }
  .icon-btn:active { transform: translateY(1.62px); }
  .icon-btn.primary { background: var(--db-accent); border-color: var(--db-accent); color: var(--db-accent-text); }
  .icon-btn.primary:hover { background: var(--db-accent-hover); border-color: var(--db-accent-hover); }
  .submit-btn {
    display: inline-flex; align-items: center; gap: 9.72px;
    height: 45.36px; padding: 0 21.06px; cursor: pointer;
    border-radius: 11.34px; border: 1.62px solid var(--db-accent);
    background: var(--db-accent); color: var(--db-accent-text);
    font: inherit; font-size: 19.44px; font-weight: 600;
    transition: background .15s, border-color .15s, transform .08s;
  }
  .submit-btn svg { width: 22.68px; height: 22.68px; }
  .submit-btn:hover { background: var(--db-accent-hover); border-color: var(--db-accent-hover); }
  .submit-btn:active { transform: translateY(1.62px); }
  body { padding-top: 64.8px; padding-bottom: 64.8px; }   /* clear the fixed header + footer bars */
  .btn {
    font-size: 19.44px; padding: 12.96px 25.92px; cursor: pointer; border-radius: 0;
    border: 1.62px solid var(--db-accent); background: var(--db-accent); color: var(--db-accent-text); font-weight: 600;
    transition: background .15s, color .15s, border-color .15s;
  }
  .btn:hover { background: var(--db-accent-hover); border-color: var(--db-accent-hover); }
  .btn.secondary { background: var(--db-surface); color: var(--db-text); border-color: var(--db-emphasis); }
  .btn.secondary:hover { background: var(--db-emphasis); }

  /* Segmented controls (theme + language) */
  .tool-left { margin-right: auto; display: flex; align-items: center; gap: 12.96px; }
  .seg-switch {
    display: inline-flex;
    align-items: center;
    border: 1.62px solid var(--db-emphasis);
    background: var(--db-surface);
    border-radius: 11.34px;
    overflow: hidden;
  }
  .seg-switch .seg {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--db-text);
    font: inherit; font-size: 17.82px;
    padding: 6.48px 14.58px;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 8.1px;
    opacity: .6;
    transition: background .15s, opacity .15s;
  }
  .seg-switch .seg svg { width: 22.68px; height: 22.68px; display: block; }
  .seg-switch .seg + .seg { border-left: 1.62px solid var(--db-emphasis); }
  .seg-switch .seg[aria-pressed="true"] { background: var(--db-emphasis); opacity: 1; font-weight: 600; }
  .seg-switch .seg:hover { opacity: 1; }

  /* Drawbridge credit (screen only) */
  .db-credit {
    position: relative; z-index: 1;
    max-width: 340.2mm; margin: 42.12px auto 42.12px;
    display: flex; align-items: center; justify-content: center; gap: 11.34px;
    font-size: 17.82px; letter-spacing: 0.486px; color: var(--db-text); opacity: .7;
  }
  .db-credit .db-logo { height: 24.3px; width: auto; display: block; position: relative; top: 1.62px; }

  /* Drawbridge background watermark (screen only) */
  .bg-watermark {
    position: fixed;
    right: -97.2px;
    bottom: -81px;
    width: 777.6px;
    height: 453.6px;
    z-index: 0;
    pointer-events: none;
    background: url("drawbridge-mark.svg") no-repeat center / contain;
    opacity: var(--wm-opacity);
  }

  /* === Easter eggs (screen only) === */
  .db-logo { cursor: pointer; }
  @keyframes bridge-raise { 0% { transform: rotate(0); } 28% { transform: rotate(-36deg); } 62% { transform: rotate(-36deg); } 100% { transform: rotate(0); } }
  .db-logo.raise { animation: bridge-raise 1.4s cubic-bezier(.5,.05,.4,1); transform-origin: 0% 100%; }
  .eg-toast {
    position: fixed; left: 50%; bottom: 45.36px; transform: translate(-50%, 19.44px);
    background: var(--db-accent); color: var(--db-accent-text);
    font-size: 21.06px; font-weight: 600; padding: 14.58px 25.92px;
    box-shadow: 0 9.72px 35.64px rgba(0,0,0,.32); opacity: 0; pointer-events: none;
    z-index: 70; transition: opacity .25s ease, transform .25s ease;
  }
  .eg-toast.show { opacity: 1; transform: translate(-50%, 0); }
  .eg-toast.ok { background: var(--ok); }
  @keyframes eg-float { 0% { opacity: 1; transform: translateY(0) rotate(0deg); } 100% { opacity: 0; transform: translateY(-153.9px) rotate(45deg); } }
  .eg-confetti { position: fixed; z-index: 70; pointer-events: none; font-size: 32.4px; animation-name: eg-float; animation-timing-function: ease-out; animation-fill-mode: forwards; }
  @keyframes eg-pop { 0% { transform: scale(0); } 60% { transform: scale(1.45); } 100% { transform: scale(1); } }
  .bday-badge { display: inline-block; margin-left: 9.72px; font-size: 25.92px; animation: eg-pop .45s ease; }
  @keyframes maple-fall {
    0%   { transform: translateY(-8vh) rotate(0deg); opacity: 0; }
    12%  { opacity: 1; }
    100% { transform: translateY(108vh) rotate(420deg); opacity: 0; }
  }
  .eg-maple { position: fixed; top: 0; z-index: 70; pointer-events: none; animation-name: maple-fall; animation-timing-function: ease-in; animation-fill-mode: forwards; }

  @page { size: A4; margin: 0; }

  /* honeypot (spam trap) — off-screen, never shown to humans */
  .hp-field { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

  /* submission success overlay (screen-only) */
  .submit-overlay { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
    background: rgba(16,2,28,.55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); padding: 24px; }
  .submit-overlay[hidden] { display: none; }
  .submit-card { background: var(--paper); color: var(--ink); border-radius: 12px; padding: 32px 36px; max-width: 460px; width: 100%;
    text-align: center; box-shadow: 0 18px 60px rgba(0,0,0,.35); border-top: 6px solid var(--brand); }
  .submit-check { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%; background: #1f9d55; color: #fff;
    font-size: 38px; line-height: 64px; font-weight: 700; }
  .submit-card h2 { margin: 0 0 6px; color: var(--brand-dark); font-size: 24px; }
  .submit-msg { margin: 0 0 4px; color: var(--muted); }
  .submit-ref { margin: 0 0 20px; font-weight: 700; font-size: 14px; }
  .submit-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
  .db-btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 700; font-size: 15px;
    padding: 10px 18px; border-radius: 8px; cursor: pointer; text-decoration: none; border: 1.62px solid transparent; }
  .db-btn.primary { background: var(--db-accent); color: var(--db-accent-text); border-color: var(--db-accent); }
  .db-btn.primary:hover { background: var(--db-accent-hover); border-color: var(--db-accent-hover); }
  .db-btn.ghost { background: transparent; color: var(--db-text); border-color: var(--db-emphasis); }
  .db-btn.ghost:hover { background: var(--db-emphasis); }
  .eg-toast.err { background: var(--err); color: #fff; }

  /* server /print/{id} render mode: hide interactive chrome on screen too */
  html.print-mode .toolbar, html.print-mode .bottombar, html.print-mode .add-benef,
  html.print-mode .remove-benef, html.print-mode #submitOverlay { display: none !important; }
  html.print-mode body { padding-top: 0 !important; padding-bottom: 0 !important; }

  @media print {
    /* Printing is ALWAYS light, regardless of the on-screen theme */
    :root, html[data-theme="dark"] {
      --ink: #10021c; --line: #9a93a0; --line-strong: #5b4f63; --muted: #6b6275;
      --brand-dark: #10021c; --shade: #fbf2ee; --shade-bar: #fbe1d6;
      --paper: #ffffff; --paper-2: #fcfdff; --focus-bg: #fff3ef; --comb-focus: #ffe7dd;
      --logo-plate: transparent;
    }
    html { zoom: 0.6173; }   /* undo the 1.8x screen scale for print */
    body { background: #fff; padding-top: 0; padding-bottom: 0; }
    .page {
      box-shadow: none; margin: 0; border-radius: 0;
      width: 340.2mm; min-height: 481.14mm; padding: 9.72mm 21.06mm;
      page-break-after: always;
    }
    html[data-theme="dark"] header .logo { padding: 0; background: none; }
    section.page:last-of-type { page-break-after: auto; }
    .toolbar, .bottombar, .bg-watermark, .db-credit, .eg-toast, .eg-confetti, .bday-badge, .eg-maple, #marks, .add-benef, .remove-benef, #submitOverlay { display: none !important; }
    select.rel-select { background-image: none; }
    /* keep submitted (disabled/readonly) fields fully legible on paper */
    input, select, textarea { color: var(--ink) !important; -webkit-text-fill-color: var(--ink) !important; opacity: 1 !important; }
  }

  /* once submitted (or on the /print view) the form is locked; stop the custom picker opening */
  .form-locked .select { pointer-events: none; }
