
  :root {
    --blue: #0B3EA9;
    --sky: #59AFFF;
    --sun: #F5BE1A;
    --ink: #111111;
    --on: #ffffff;
    --paper: #ffffff;
    --quiet: #111111;
    --line: rgba(17, 17, 17, 0.16);
    --frame: var(--blue);
    --frame-soft: #deefff;
    --debt: #b42318;
    --paid: #1d6b45;
    --over: #C49200;
    --tray: #eaf6ff;
    --sheet: #ffffff;
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; min-height: 100%; max-width: 100%; overflow-x: hidden; }
  body {
    background: var(--paper);
    color: var(--ink);
    font-family: Karla, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.45;
  }
  #app { min-height: 100vh; }
  .app { display: grid; grid-template-columns: 232px 1fr 280px; min-height: 100vh; width: 100%; max-width: 100%; overflow-x: clip; }
  .index, .tray { padding: 22px 16px; }
  .index { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 100%; position: relative; z-index: 5; overflow: visible; }
  .tray { background: var(--tray); border-left: 1px solid var(--line); }
  .place { margin: 0 0 18px; font-weight: 720; font-size: 28px; letter-spacing: -0.03em; }
  .acts { display: flex; flex-wrap: wrap; gap: 8px 14px; }
  .lenses { display: flex; gap: 10px; margin: 0; }
  button, .jump {
    font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
  }
  .lenses button { text-align: center; padding: 8px 0; color: var(--ink); background: var(--sheet); border: 1px solid var(--line); }
  .lenses button[aria-pressed="true"] { color: var(--on); background: var(--blue); border-color: var(--blue); font-weight: 720; }
  .add { margin: 0; padding: 0; border: 0; }
  .add > button, .add .menu button, .acts button, button[data-cancel], button[data-back] {
    color: var(--ink); background: var(--sheet); border: 1px solid var(--blue); padding: 8px 12px; text-align: center;
  }
  .add .menu { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 10px; }
  .add .menu button { text-align: left; }
  .idx button { display: block; width: 100%; margin: 0 0 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .idx button[aria-pressed="true"] { box-shadow: inset 3px 0 var(--sun); padding-left: 10px; }
  .idx b { display: block; font-size: 17px; font-weight: 720; }
  .idx span, .quiet { color: var(--quiet); }
  .idx span { font-size: 14px; }
  main { padding: 22px 28px 64px; }
  .who { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
  .who-end { display: flex; align-items: baseline; gap: 18px; margin-left: auto; flex-shrink: 0; }
  .who-end .add > button {
    white-space: nowrap;
    border: 0 !important;
    background: none !important;
    box-shadow: none !important;
    padding: 0;
    color: var(--ink);
    text-decoration: underline dashed;
    text-underline-offset: 4px;
  }
  h1 { margin: 0; font-size: 34px; font-weight: 720; letter-spacing: -0.03em; line-height: 1.05; flex: 1; min-width: 0; }
  .who-end .add { align-self: baseline; }
  .sum { font-size: 26px; font-weight: 720; letter-spacing: -0.03em; text-align: right; }
  .sum em { display: block; font-style: normal; font-size: 14px; font-weight: 720; margin-top: 2px; }
  .sum em.bad { color: #b42318; }
  .sum em.ok { color: #1d6b45; }
  .sum em.settled { font-weight: 500; color: var(--muted, #666); }
  .over { color: var(--over); }
  .sum .debt, .sum .over { font-weight: 720; }
  .sum .paid-total { display: block; font-size: 14px; font-weight: 420; margin-top: 4px; color: var(--quiet); }
  .facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px 20px; margin: 18px 0 0; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .contract-sheet { display: grid; gap: 18px; max-width: 62ch; margin-top: 4px; }
  .contract-sheet b { display: block; font-size: 13px; font-weight: 560; color: var(--quiet); margin-bottom: 4px; }
  .contract-sheet p { margin: 0; }
  .contract-sheet ul { margin: 0; padding-left: 18px; }
  .contract-sheet li { margin: 4px 0; }
  .facts b { display: block; font-size: 13px; font-weight: 560; color: var(--quiet); margin-bottom: 4px; }
  .facts p { margin: 0; }
  .detail-below { margin-top: 22px; }
  .detail-below > h2 { margin: 0 0 8px; font-size: 20px; font-weight: 720; }
  .detail-below .head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 8px; }
  .detail-below .head h2 { margin: 0; }
  .detail-below .head button {
    color: var(--ink);
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    text-decoration: underline dashed;
    text-underline-offset: 4px;
    cursor: pointer;
  }
  .people-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 16px;
    margin: 22px 0 16px;
    padding: 0;
  }
  .people-filter button {
    color: var(--quiet);
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    padding: 4px 8px 6px;
    font: inherit;
    font-size: 14px;
    font-weight: 420;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
  }
  .people-filter button[aria-pressed="true"] {
    color: var(--ink);
    font-weight: 720;
    border-bottom-color: var(--blue);
    background: var(--frame-soft);
    box-shadow: inset 0 0 0 1px rgba(11, 62, 169, 0.18);
  }
  .people-filter button[aria-pressed="true"]::before {
    content: "✓ ";
    font-weight: 720;
    color: var(--blue);
  }
  .people-filter-count {
    margin-left: auto;
    font-size: 13px;
    font-weight: 560;
    color: var(--quiet);
    padding: 4px 0;
  }
  .jump { color: var(--ink); font-weight: 720; text-decoration: underline; text-underline-offset: 3px; }
  .acts { margin: 0 0 18px; }
  .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
  h2 { margin: 0 0 8px; font-size: 20px; font-weight: 720; }
  table { width: 100%; border-collapse: separate; border-spacing: 0; }
  th, td { text-align: left; padding: 8px 8px 8px 0; vertical-align: top; border-bottom: 1px solid var(--line); }
  td[rowspan] { border-bottom: 1px solid var(--line); }
  th { font-size: 13px; font-weight: 560; color: var(--quiet); }
  .pair th:first-child, .pair td:first-child { padding-left: 10px; }
  .pair th:last-child, .pair td:last-child { padding-right: 10px; }

  .drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    margin: 0 8px 0 -4px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    outline: none;
    color: var(--quiet);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    vertical-align: middle;
    font: inherit;
  }
  .drag-handle svg {
    width: 22px;
    height: 22px;
    display: block;
    pointer-events: none;
    fill: currentColor;
  }
  .drag-handle:active { cursor: grabbing; color: var(--ink); }
  tr.unit-dragging { opacity: 0.35; }
  tr.unit-drop-over td {
    background: var(--frame-soft);
  }
  tr.unit-drop-head td {
    box-shadow: inset 0 2px 0 var(--blue);
  }
  body.unit-dnd {
    cursor: grabbing;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
  }
  .unit-ghost {
    position: fixed;
    z-index: 40;
    pointer-events: none;
    background: var(--sheet);
    border: 1px solid var(--blue);
    box-shadow: 0 10px 28px rgba(17, 17, 17, 0.18);
    padding: 10px 14px;
    max-width: min(280px, 80vw);
    font-weight: 720;
  }
  .unit-ghost .quiet {
    display: block;
    margin-top: 4px;
    font-weight: 420;
    font-size: 13px;
  }

  .unit-cards { display: flex; flex-direction: column; gap: 0; }
  .unit-card {
    border-bottom: 1px solid var(--line);
    padding: 12px 0;
  }

  .unit-card-head > button {
    font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
  }
  .unit-card-people .who-name {
    font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
    text-decoration: underline; text-underline-offset: 3px; font-weight: 720;
  }
  .unit-card-head {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 0 8px;
  }
  .unit-card-head h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 720;
    line-height: 1.2;
  }
  .unit-card-people {
    list-style: none;
    margin: 0;
    padding: 0 0 0 40px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .unit-card-people li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
  }
  .unit-card-people .who-name { min-width: 0; }
  .unit-card-people .who-owe { flex-shrink: 0; text-align: right; }
  .unit-card.unit-dragging { opacity: 0.35; }
  .unit-card.unit-drop-over {
    background: var(--frame-soft);
  }
  .unit-card.unit-drop-head {
    box-shadow: inset 0 2px 0 var(--blue);
  }
  @media (min-width: 761px) {
    .unit-card {
      display: grid;
      grid-template-columns: minmax(140px, 0.35fr) 1fr;
      gap: 12px 20px;
      align-items: start;
      padding: 14px 0;
    }
  
  .unit-card-head > button {
    font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
  }
  .unit-card-people .who-name {
    font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
    text-decoration: underline; text-underline-offset: 3px; font-weight: 720;
  }
  .unit-card-head { margin: 0; }
    .unit-card-people { padding-left: 0; }
  }
  tr[data-id], tr[data-open] { cursor: pointer; }
  tr.linked td { background: var(--frame-soft); }
  tr.source td {
    background: var(--frame-soft);
    border-top: 2px solid var(--frame);
    border-bottom: 2px solid var(--frame);
  }
  tr.source td:first-child { border-left: 2px solid var(--frame); padding-left: 10px; }
  tr.source td:last-child { border-right: 2px solid var(--frame); padding-right: 10px; }
  tr.linked td:first-child { padding-left: 10px; }
  tr.linked td:last-child { padding-right: 10px; }
  .debt { color: var(--debt); font-weight: 720; }
  .paid { color: var(--paid); font-weight: 720; }
  .over { color: var(--over); font-weight: 720; }

  .pick-detail {
    margin: 14px 0 0;
    padding: 12px 0 0;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 10px 20px;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
  .pick-detail > div b {
    display: block;
    font-size: 13px;
    font-weight: 560;
    color: var(--quiet);
    margin-bottom: 4px;
  }
  .pick-detail > div p { margin: 0; }
  .pick-detail ul {
    margin: 0;
    padding-left: 18px;
  }
  .pick-detail li { margin: 2px 0; }
  .pick-hint { margin: 12px 0 0; color: var(--quiet); }
  .link { margin: 12px 0 0; max-width: 62ch; }
  .ctx { background: var(--frame-soft); margin: 0 0 14px; max-width: 62ch; padding: 0; }
  .ctx-row { padding: 10px 12px; }
  .ctx-row + .ctx-row { border-top: 1px solid var(--line); }
  .ctx b, .ctx-row b { display: block; font-size: 13px; font-weight: 560; margin-bottom: 2px; }
  .mpick { position: relative; display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--quiet); }
  .mpick-caption { font-size: 14px; color: var(--quiet); }
  .mpick > button[data-mpick-open] {
    font: inherit; color: var(--ink); background: white; border: 1px solid var(--line); padding: 8px 10px; text-align: left; cursor: pointer;
  }
  .mpick-pop {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(17, 17, 17, 0.4);
    display: flex;
    flex-direction: column;
    padding: 0;
  }
  .mpick-pop .calpanel {
    flex: 1;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 20px 16px 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: none;
    width: auto;
  }
  .mpick-pop .cal-foot { margin-top: auto; }
  .mpick-pop .cal-close { display: block; width: 100%; margin-top: 0; color: var(--ink); background: var(--sheet); border: 1px solid var(--blue); padding: 12px 14px; text-align: center; }
  .mpick-pop .months { flex: 1; align-content: center; gap: 10px; }
  .mpick-pop .months button { padding: 18px 8px; font-size: 16px; }
  .alloc { margin-top: 16px; max-width: 62ch; }
  .alloc ul { margin: 6px 0 0; padding-left: 18px; }

  button.units-pop {
    color: var(--ink);
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    text-decoration: underline dashed;
    text-underline-offset: 4px;
    cursor: pointer;
  }
  .units-pop-bg {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(17, 17, 17, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
  }
  .units-pop-card {
    background: var(--sheet);
    border: 1px solid var(--blue);
    padding: 18px 20px;
    width: min(320px, 100%);
    box-shadow: 0 8px 24px rgba(17, 17, 17, 0.16);
  }
  .units-pop-card h2 { margin: 0 0 6px; font-size: 18px; }
  .units-pop-card .quiet { margin: 0 0 10px; }
  .units-pop-card ul { margin: 0 0 14px; padding-left: 18px; }
  .units-pop-card li { margin: 4px 0; }
  .units-pop-card .close {
    color: var(--ink);
    background: none;
    border: 0;
    padding: 0;
    text-decoration: underline dashed;
    text-underline-offset: 4px;
    font: inherit;
  }


  .steps {
    display: flex;
    align-items: flex-start;
    width: 100%;
    gap: 0;
    margin: 0 0 14px;
    grid-column: 1 / -1;
  }
  .step {
    flex: 1 1 0;
    min-width: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    z-index: 0;
  }
  .step:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 13px;
    left: calc(50% + 16px);
    width: calc(100% - 32px);
    height: 2px;
    background: var(--line);
    z-index: 0;
  }
  .step.done:not(:last-child)::after {
    background: var(--blue);
  }
  .step-name {
    font-size: 12px;
    font-weight: 560;
    color: var(--quiet);
    line-height: 1.25;
    max-width: 100%;
  }
  .step.now .step-name { color: var(--ink); font-weight: 720; }
  .step.done .step-name { color: var(--ink); }
  .step.done[data-wizard-back] { cursor: pointer; }
  .step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--blue);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 720;
    line-height: 1;
    flex-shrink: 0;
    background: var(--sheet);
    color: var(--quiet);
    position: relative;
    z-index: 1;
  }
  .step.done .step-dot {
    background: var(--blue);
    border-color: var(--blue);
    color: var(--on);
  }
  .step.now .step-dot {
    background: var(--frame-soft);
    border-color: var(--blue);
    color: var(--ink);
    box-shadow: 0 0 0 2px var(--sun);
  }
  form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0 0 22px; padding: 14px 0 18px; border-bottom: 1px solid var(--line); }
  form h2, form > .quiet, form > .steps, form > .ctx, form > .mpick { grid-column: 1 / -1; }
  label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--quiet); }
  label.wide { grid-column: 1 / -1; }
  input, select { font: inherit; color: var(--ink); background: white; border: 1px solid var(--line); padding: 8px 10px; }
  input:focus, select:focus, button:focus-visible, .jump:focus-visible { outline: 2px solid var(--frame); outline-offset: 2px; }
  .choices { display: flex; flex-wrap: wrap; gap: 10px 16px; }
  .choices label { flex-direction: row; align-items: center; color: var(--ink); }
  .form-actions { grid-column: 1 / -1; display: flex; gap: 12px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
  .pick-choices { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 10px; }
  .pick-choice {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
    text-align: left;
    padding: 14px 16px;
    color: var(--ink);
    background: var(--sheet);
    border: 1px solid var(--blue);
    cursor: pointer;
  }
  .pick-choice b { font-size: 16px; font-weight: 720; }
  .pick-choice span { font-size: 14px; font-weight: 420; color: var(--quiet); }
  .pick-choice:focus-visible { background: var(--frame-soft); }
  .save { background: var(--blue); color: var(--on); border: 0; padding: 9px 14px; font: inherit; font-weight: 720; cursor: pointer; }
  .err { color: var(--debt); margin: 0; }
  .tray h2 { font-size: 18px; }
  .tray p.lead { margin: 0 0 12px; color: var(--quiet); font-size: 14px; }
  .check { display: block; width: 100%; padding: 10px 0; border: 0; border-top: 1px solid var(--line); background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
  .check b { display: block; font-weight: 720; }
  .check span { color: var(--quiet); font-size: 14px; }


  .nav-toggle { display: none; }
  .nav-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .bookpick { position: relative; }
  .bookpick > button { display: block; width: 100%; text-align: left; color: var(--ink); background: var(--sheet); border: 1px solid var(--blue); padding: 10px 12px; }
  .bookmenu, .lensmenu { position: absolute; z-index: 4; left: 0; right: 0; top: calc(100% + 4px); background: var(--sheet); border: 1px solid var(--blue); padding: 4px 0; }
  .bookmenu button, .lensmenu button { display: block; width: 100%; text-align: left; padding: 8px 12px; color: var(--ink); background: var(--sheet); border: 0; }
  .bookmenu button[aria-pressed="true"], .lensmenu button[aria-pressed="true"] { box-shadow: inset 3px 0 var(--sun); }
  .bookmenu hr { border: 0; border-top: 1px solid var(--blue); margin: 4px 0; }
  .tools { display: flex; flex-direction: row; align-items: center; gap: 10px; margin-top: 18px; }
  .lensrows { flex: 1; display: flex; flex-direction: column; gap: 8px; }
  .lensrows button { display: block; width: 100%; text-align: left; padding: 10px 12px; color: var(--ink); background: var(--sheet); border: 1px solid var(--line); }
  .lensrows button[aria-pressed="true"] { color: var(--on); background: var(--blue); border-color: var(--blue); font-weight: 720; }
  .tools .add { margin: 0; }
  .tools .add > button { white-space: nowrap; }
  .lenses { display: flex; gap: 10px; margin: 0; }
  .head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 8px; }
  .head h2 { margin: 0; }
  .head-acts { display: flex; align-items: center; gap: 16px; }
  .head button {
    color: var(--ink);
    background: none;
    border: 0;
    padding: 0;
    text-decoration: underline dashed;
    text-underline-offset: 4px;
  }
  .cal { position: relative; order: 3; margin-top: auto; padding-top: 18px; }
  .nav-toggle { order: 1; }
  .nav-body { order: 2; }
  .cal-row { display: flex; align-items: stretch; gap: 6px; }
  .cal-row > [data-cal] { flex: 1; min-width: 0; text-align: left; color: var(--ink); background: var(--sheet); border: 1px solid var(--blue); padding: 10px 12px; }
  .cal-step {
    flex: 0 0 40px;
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    background: var(--sheet);
    border: 1px solid var(--blue);
    padding: 0;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
  }
  .calgrid { position: absolute; z-index: 6; left: 0; bottom: calc(100% + 6px); width: min(300px, calc(100vw - 32px)); max-width: calc(100vw - 32px); }
  .calpanel { background: var(--sheet); border: 1px solid var(--blue); padding: 12px; box-shadow: 0 8px 24px rgba(17, 17, 17, 0.12); }
  .cal-mode { display: flex; gap: 8px; }
  .cal-mode button { flex: 1; text-align: center; color: var(--ink); background: var(--sheet); border: 1px solid var(--blue); padding: 8px 10px; }
  .cal-mode button[aria-pressed="true"] { color: var(--on); background: var(--blue); }
  .cal-hint { margin: 0; text-align: center; font-size: 14px; }
  .calyear { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
  .calyear span { flex: 0 0 auto; text-align: center; }
  .calyear button { flex: 1 1 0; min-width: 0; color: var(--ink); background: var(--sheet); border: 1px solid var(--blue); padding: 6px 10px; text-align: center; line-height: 1.2; }
  .cal-foot { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
  .cal-today { display: block; width: 100%; text-align: center; color: var(--ink); background: var(--sheet); border: 1px solid var(--blue); padding: 8px 12px; }
  .cal-close { display: none; text-align: center; }
  .months { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .months button { text-align: center; padding: 8px 4px; color: var(--ink); background: var(--sheet); border: 1px solid transparent; font-size: 14px; white-space: nowrap; }
  .months button.in-range { background: var(--frame-soft); }
  .months button[aria-pressed="true"] { background: var(--blue); color: var(--on); }
  .pair td:nth-child(2), .pair th:nth-child(2),
  .pair td:last-child, .pair th:last-child,
  .res td:last-child, .res th:last-child { width: 1%; white-space: nowrap; }
  .pair td:first-child, .res td:first-child { white-space: nowrap; }
  .facts p { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
  @media (max-width: 1080px) {
    .app { grid-template-columns: 220px 1fr; }
    .tray { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  }
  @media (max-width: 760px) {
    .app { grid-template-columns: 1fr; overflow-x: hidden; }
    .index, main, .tray, #stage, .who, .who-end, .pair, .facts, form, table { min-width: 0; max-width: 100%; }
    .index { border-right: 0; border-bottom: 1px solid var(--line); overflow: hidden; }
    main { padding: 12px 10px 32px; overflow-x: hidden; }
    .facts, .pair, form { grid-template-columns: 1fr; }
    .who { align-items: baseline; flex-wrap: nowrap; gap: 12px; }
    .who-end { margin-left: auto; width: auto; flex-shrink: 0; justify-content: flex-end; }
    .sum { text-align: left; }
    h1 { font-size: 24px; max-width: 100%; overflow-wrap: anywhere; }
    .sum { font-size: 20px; }
    .nav-toggle { padding: 10px 12px; }
    .nav-body { margin-top: 8px; }
    table { width: 100%; }
    th, td { word-break: normal; }
    .pair td:first-child, .res td:first-child {
      white-space: normal;
      overflow-wrap: anywhere;
    }
    .pair th:nth-child(2), .pair td:nth-child(2),
    .pair th:last-child, .pair td:last-child,
    .res th:last-child, .res td:last-child {
      white-space: nowrap;
      width: 1%;
      word-break: keep-all;
      overflow-wrap: normal;
    }
    .pair table {
      overflow-x: auto;
      display: block;
      width: 100%;
    }
    .pair thead, .pair tbody { display: table; width: 100%; }
    .bookmenu, .lensmenu { max-width: 100%; }
    .nav-toggle {
      display: flex;
      width: 100%;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      color: var(--ink);
      background: var(--sheet);
      border: 1px solid var(--blue);
      padding: 12px 14px;
      font-weight: 720;
      text-align: left;
    }
    .nav-toggle::after { content: "▼"; font-weight: 420; font-size: 12px; }
    .index.is-open .nav-toggle::after { content: "▲"; }
    .nav-body { display: none; margin-top: 12px; gap: 0; }
    .index.is-open .nav-body { display: flex; }
    .cal {
      order: 2;
      display: block;
      margin-top: 8px;
      padding-top: 0;
    }
    .nav-body { order: 3; }
    .nav-toggle { order: 1; }
    .index, .tray { padding: 10px; }
    .index { min-height: 0; padding-bottom: 10px; }
    .calgrid {
      position: fixed;
      inset: 0;
      left: 0;
      bottom: 0;
      width: auto;
      max-width: none;
      z-index: 50;
      background: rgba(17, 17, 17, 0.4);
      padding: 0;
      display: flex;
      flex-direction: column;
    }
    .calpanel {
      flex: 1;
      border: 0;
      border-radius: 0;
      box-shadow: none;
      padding: 20px 16px 28px;
      display: flex;
      flex-direction: column;
      gap: 16px;
    }
    .calyear { margin-bottom: 0; }
    .calyear button { padding: 10px 12px; }
    .months { flex: 1; align-content: center; gap: 10px; }
    .months button { padding: 18px 8px; font-size: 16px; }
    .cal-foot { margin-top: auto; }
    .cal-today { padding: 12px 14px; }
    .cal-close {
      display: block;
      width: 100%;
      margin-top: 0;
      color: var(--ink);
      background: var(--sheet);
      border: 1px solid var(--blue);
      padding: 12px 14px;
      text-align: center;
    }
  }

  /* --- loading-state demo (six rules) --- */
  .load-demo {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
    margin: 0 0 14px; padding: 6px 0 10px;
    border-bottom: 1px dashed var(--line);
    font-size: 12px; color: var(--quiet);
  }
  .load-demo-kicker { font-weight: 560; letter-spacing: 0.02em; margin-right: 4px; color: var(--quiet); }
  .load-demo button {
    font: inherit; font-size: 12px; font-weight: 420;
    color: var(--quiet); background: transparent;
    border: 1px solid transparent; border-radius: 999px;
    padding: 3px 10px; cursor: pointer;
  }
  .load-demo button[aria-pressed="true"] {
    color: var(--blue); font-weight: 560;
    border-color: var(--blue); background: var(--frame-soft);
  }
  button.is-pending, .people-filter button.is-pending, .cal-step.is-pending, .who-end .add > button.is-pending {
    opacity: 0.55; pointer-events: none;
    box-shadow: inset 0 0 0 1px var(--blue);
  }
  .list-shell, .pair, .detail-below, .money-shell {
    min-height: 0;
  }
  .list-shell { min-height: 260px; }
  .pair { min-height: 200px; }
  .money-shell { min-height: 200px; }
  .detail-below { min-height: 112px; }
  .skel-row {
    display: grid; gap: 8px; padding: 12px 0;
    border-bottom: 1px solid var(--line);
  }
  .skel-line {
    height: 12px; border-radius: 4px;
    background: linear-gradient(90deg, rgba(11,62,169,0.08) 0%, rgba(245,190,26,0.18) 45%, rgba(11,62,169,0.08) 90%);
    background-size: 220% 100%;
    animation: skel-shimmer 1.15s ease-in-out infinite;
  }
  .skel-name { width: 42%; height: 14px; }
  .skel-quiet { width: 28%; height: 10px; opacity: 0.85; }
  .skel-row.skel-table {
    grid-template-columns: 1.4fr 0.7fr 0.6fr; align-items: center; gap: 16px;
  }
  .skel-row.skel-table .skel-line { width: 100%; }
  @keyframes skel-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
  }
  .load-fail {
    margin: 8px 0 0; padding: 14px 16px;
    border: 1px solid var(--debt); background: #fff6f5;
    min-height: 120px;
  }
  .load-fail p { margin: 0 0 12px; font-weight: 560; }
  .load-fail-acts { display: flex; flex-wrap: wrap; gap: 10px 14px; }
  .load-fail-acts button {
    font: inherit; cursor: pointer; padding: 8px 12px;
    border: 1px solid var(--blue); background: var(--sheet); color: var(--ink);
  }
  .load-fail-acts button[data-load-retry] {
    background: var(--blue); color: var(--on); border-color: var(--blue); font-weight: 720;
  }
  .sync-panel {
    margin: 8px 0 0; padding: 14px 16px;
    border: 1px solid var(--line); background: var(--frame-soft);
    min-height: 120px;
  }
  .sync-panel .sync-label { margin: 0 0 10px; font-weight: 560; }
  .sync-bar {
    height: 10px; border-radius: 999px; background: rgba(17,17,17,0.08);
    overflow: hidden;
  }
  .sync-bar-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--blue), var(--sky));
    transition: width 0.25s ease;
  }
  .sync-meta { margin: 8px 0 0; font-size: 13px; color: var(--quiet); }
  .sync-ok { margin: 8px 0 0; color: var(--paid); font-weight: 560; }

  /* --- empty states (designmotionhq) --- */
  .empty-state {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin: 8px 0 0;
    padding: 18px 16px;
    border: 1px dashed var(--line);
    background: var(--frame-soft);
    max-width: 42ch;
  }
  .empty-state.money-empty {
    margin: 4px 0 8px;
    max-width: none;
    width: 100%;
    box-sizing: border-box;
  }
  .empty-glyph {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--sheet);
    border: 1px solid var(--blue);
    color: var(--blue);
    font-size: 18px;
    font-weight: 720;
    line-height: 1;
    flex-shrink: 0;
  }
  .empty-state h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 720;
    letter-spacing: -0.01em;
  }
  .empty-state p {
    margin: 0;
    font-size: 14px;
    color: var(--quiet);
    max-width: 36ch;
  }
  .empty-state .empty-cta {
    margin-top: 4px;
    color: var(--on);
    background: var(--blue);
    border: 1px solid var(--blue);
    padding: 9px 14px;
    font: inherit;
    font-weight: 720;
    cursor: pointer;
    text-decoration: none;
  }
  .empty-state .empty-cta.secondary {
    color: var(--ink);
    background: var(--sheet);
  }

  /* --- toasts (never centered) --- */
  .toast-host {
    position: fixed;
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    right: 16px;
    bottom: 16px;
    left: auto;
    top: auto;
    align-items: flex-end;
    max-width: min(360px, calc(100vw - 24px));
  }
  @media (max-width: 760px) {
    .toast-host {
      top: 12px;
      bottom: auto;
      right: 12px;
      left: 12px;
      align-items: stretch;
      max-width: none;
    }
  }
  .toast {
    pointer-events: auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px 12px;
    align-items: start;
    width: 100%;
    max-width: 360px;
    padding: 12px 14px 10px;
    background: var(--sheet);
    border: 1px solid var(--line);
    border-left: 4px solid var(--paid);
    box-shadow: 0 8px 24px rgba(17, 17, 17, 0.14);
    color: var(--ink);
    font-size: 14px;
    position: relative;
    overflow: hidden;
  }
  .toast-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e8f5ee;
    color: var(--paid);
    font-weight: 720;
    flex-shrink: 0;
  }
  .toast-body { min-width: 0; }
  .toast-body b { display: block; font-weight: 720; margin-bottom: 2px; }
  .toast-body span { color: var(--quiet); font-size: 13px; }
  .toast-undo {
    font: inherit;
    font-weight: 720;
    color: var(--blue);
    background: none;
    border: 0;
    padding: 4px 0;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    white-space: nowrap;
  }
  .toast-bar {
    grid-column: 1 / -1;
    height: 3px;
    background: rgba(17, 17, 17, 0.08);
    margin: 2px -14px -10px;
    overflow: hidden;
  }
  .toast-bar > i {
    display: block;
    height: 100%;
    width: 100%;
    transform-origin: left center;
    background: var(--paid);
    animation: toast-drain linear forwards;
  }
  .toast.is-paused .toast-bar > i { animation-play-state: paused; }
  @keyframes toast-drain {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
  }

  /* hover trap: tint/extras only when fine pointer can hover */
  @media (hover: hover) {
    .drag-handle:hover { color: var(--ink); }
    .cal-step:hover { background: var(--frame-soft); }
    .people-filter button:hover { color: var(--ink); }
    .people-filter button[aria-pressed="true"]:hover { color: var(--ink); }
    .step.done[data-wizard-back]:hover .step-name { text-decoration: underline; text-underline-offset: 3px; }
    .pick-choice:hover { background: var(--frame-soft); }
    .load-demo button:hover { color: var(--ink); border-color: var(--line); }
    tr[data-open]:hover td, tr[data-id]:hover td { background: rgba(222, 239, 255, 0.45); }
    tr.source:hover td, tr.linked:hover td { background: var(--frame-soft); }
  }
  @media (pointer: coarse) {
    .drag-handle {
      width: 44px;
      height: 44px;
      min-width: 44px;
      min-height: 44px;
    }
    .cal-step {
      flex: 0 0 44px;
      min-width: 44px;
      min-height: 44px;
    }
  }

  /* --- form network error (draft-safe) --- */
  form > .form-net-err, form > .sim-net, form > .spick { grid-column: 1 / -1; }
  .form-net-err {
    display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 14px;
    margin: 0; padding: 12px 14px;
    border: 1px solid var(--debt); border-left: 4px solid var(--debt);
    background: #fdf2f1; color: var(--ink);
    transition: opacity 0.2s ease, transform 0.2s ease;
  }
  .form-net-err b { display: block; font-weight: 720; margin-bottom: 2px; }
  .form-net-err span { display: block; font-size: 13px; color: var(--quiet); }
  .form-net-err button {
    font: inherit; font-weight: 720; cursor: pointer;
    padding: 8px 12px; border: 1px solid var(--debt);
    background: var(--sheet); color: var(--ink);
  }
  .sim-net {
    display: flex; flex-direction: row; align-items: center; gap: 8px;
    font-size: 13px; color: var(--quiet); margin: 0; cursor: pointer;
  }
  .sim-net input { width: auto; margin: 0; }

  /* --- searchable picker --- */
  .spick {
    display: flex; flex-direction: column; gap: 6px;
    font-size: 14px; color: var(--quiet);
  }
  .spick-caption { font-size: 14px; }
  .spick-q {
    font: inherit; color: var(--ink); background: white;
    border: 1px solid var(--line); padding: 8px 10px;
  }
  .spick-meta {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 12px; color: var(--quiet); min-height: 1.2em;
  }
  .spick-meta button {
    font: inherit; font-size: 12px; color: var(--blue); background: none;
    border: 0; padding: 0; cursor: pointer; text-decoration: underline;
    text-underline-offset: 2px;
  }
  .spick-list {
    max-height: 220px; overflow: auto;
    border: 1px solid var(--line); background: var(--sheet);
    display: flex; flex-direction: column;
  }
  .spick-opt {
    display: block; width: 100%; text-align: left;
    padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line);
    background: var(--sheet); color: var(--ink); font: inherit; cursor: pointer;
    transition: background 0.15s ease;
  }
  .spick-opt:last-child { border-bottom: 0; }
  .spick-opt[aria-selected="true"] {
    background: var(--frame-soft); font-weight: 720;
    box-shadow: inset 3px 0 var(--sun);
  }
  .spick-empty {
    padding: 14px 12px; color: var(--quiet); font-size: 13px;
  }
  .spick-empty button {
    font: inherit; font-size: 13px; color: var(--blue); background: none;
    border: 0; padding: 0; cursor: pointer; text-decoration: underline;
    text-underline-offset: 2px;
  }


  /* micro-motion ≤250ms */
  .toast {
    animation: toast-in 0.2s ease;
  }
  @keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .empty-state {
    transition: opacity 0.2s ease;
  }
  .people-filter button {
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  }



/* Static pages use links where the operator uses buttons. Same shapes. */
.bookpick > summary {
  display: block;
  width: 100%;
  text-align: left;
  list-style: none;
  cursor: pointer;
  color: var(--ink);
  background: var(--sheet);
  border: 1px solid var(--blue);
  padding: 10px 12px;
}
.bookpick > summary::-webkit-details-marker { display: none; }
.bookmenu a {
  display: block;
  width: 100%;
  text-align: left;
  text-decoration: none;
  padding: 8px 12px;
  color: var(--ink);
}
.bookmenu a[aria-current="page"] { box-shadow: inset 3px 0 var(--sun); }
.lensrows a {
  display: block;
  width: 100%;
  text-align: left;
  text-decoration: none;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--sheet);
  border: 1px solid var(--line);
}
.lensrows a[aria-current="page"] {
  color: var(--on);
  background: var(--blue);
  border-color: var(--blue);
  font-weight: 720;
}
.cal-row > a[data-cal] { text-decoration: none; }
.who-end .add > a {
  white-space: nowrap;
  border: 0;
  background: none;
  padding: 0;
  color: var(--ink);
  font-weight: 720;
  text-decoration: underline dashed;
  text-underline-offset: 4px;
}
a.check { text-decoration: none; }
a.pick-choice, a.empty-cta { text-decoration: none; color: inherit; }
a.pick-choice b { display: block; }
tr[data-open] a, .unit-card-head a, a.who-name {
  color: inherit;
  text-decoration: none;
}
.contract-sheet a, .facts a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}
a.who-name { text-decoration: underline; text-underline-offset: 3px; font-weight: 720; }
.unit-card-head a h3 { margin: 0; font-size: 17px; font-weight: 720; }
.form-actions a[data-cancel] {
  color: var(--ink);
  background: var(--sheet);
  border: 1px solid var(--blue);
  padding: 8px 12px;
  text-align: center;
  text-decoration: none;
}
.cal-mode a, .calyear a, .months a, a.cal-today, a.cal-close {
  text-decoration: none;
  color: var(--ink);
  background: var(--sheet);
  border: 1px solid var(--blue);
  font: inherit;
}
.cal-mode a { flex: 1; text-align: center; padding: 8px 10px; }
.cal-mode a[aria-current="page"] { color: var(--on); background: var(--blue); }
.calyear a { flex: 1 1 0; min-width: 0; text-align: center; padding: 6px 10px; }
.months a {
  text-align: center;
  padding: 8px 4px;
  border-color: transparent;
  font-size: 14px;
}
.months a.in { background: var(--frame-soft); }
.months a[aria-current="page"] { background: var(--blue); color: var(--on); border-color: var(--blue); }
a.cal-today, a.cal-close { display: block; width: 100%; text-align: center; padding: 8px 12px; }
.nav-check {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
label.choice {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  grid-column: 1 / -1;
}
.sheet-page { max-width: 420px; margin-top: 18px; }
.sheet-page .calpanel { position: static; box-shadow: none; }
@media (max-width: 760px) {
  .nav-check:checked + .nav-toggle::after { content: "▲"; }
  .nav-check:checked + .nav-toggle + .nav-body { display: flex; }
}
