/* Ledger: pale ruled paper, navy ink, tax in red ink. One family (Archivo), width axis does the work. */
/* Archivo (SIL Open Font License), self-hosted latin subset of the variable font so no visitor
   request goes to a third party. */
@font-face {
  font-family: "Archivo"; font-style: normal; font-weight: 300 900; font-stretch: 62% 125%;
  font-display: swap; src: url("fonts/archivo-latin.woff2") format("woff2");
}
:root {
  color-scheme: light;
  --paper: #eef2ea;
  --sheet: #ffffff;
  --ink: #1b2a41;
  --ink-2: #4a5a70;
  --ink-3: #6b7a8c;
  --rule: #c9d3c4;
  --red: #b3261e;
  --keep: #aeb9c9;
  --me: #0f6e6e;          /* identity: me (teal) */
  --them: #9a5b00;        /* identity: them (ochre) */
  --margin: #e2a39d;      /* ledger paper's red margin rule (decorative, pale) */
  --focus: #1b2a41;
  --fig-max: min(24vw, 7rem);
  --sans: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #142030;
    --sheet: #1b2a3d;
    --ink: #e6ece3;
    --ink-2: #b8c3cf;
    --ink-3: #8d9bab;
    --rule: #2f3f55;
    --red: #f0776c;
    --keep: #46597a;
    --me: #5cc2bb;
    --them: #e0a548;
    --margin: #6e3a37;
    --focus: #e6ece3;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 17px/1.5 var(--sans);
  font-variation-settings: "wdth" 100;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 20px; }

/* ---- Top ---- */
.top { padding: 40px 20px 8px; }
h1 {
  font-size: clamp(30px, 7vw, 46px); line-height: 1.05; margin: 0 0 12px;
  font-weight: 800; font-variation-settings: "wdth" 112; letter-spacing: -0.01em;
}
.lede { margin: 0; color: var(--ink-2); font-size: 16px; max-width: 52ch; }

/* ---- Inputs: two ledger lines ---- */
.ledger { margin: 22px 0 0; border-top: 2px solid var(--ink); border-left: 4px double var(--margin); padding-left: 14px; }
.line[data-who="a"] { --who: var(--me); }
.line[data-who="b"] { --who: var(--them); }
.line { padding: 12px 0 14px; border-bottom: 1px solid var(--rule); }
.line-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.line-head label { font-weight: 700; font-size: 15px; color: var(--who); }
.job-chip { font-size: 14px; color: var(--ink-2); font-variation-settings: "wdth" 85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.job-chip:empty::before { content: "\00a0"; }
.money-input { display: flex; align-items: baseline; font-weight: 700; font-size: 34px; font-variation-settings: "wdth" 110; line-height: 1.15; }
.money-input span { color: var(--who); opacity: 0.6; margin-right: 2px; }
.money-input input {
  font: inherit; font-variation-settings: inherit; color: var(--who); background: transparent;
  border: 0; border-bottom: 1px dashed transparent; padding: 0; width: 100%; min-width: 0;
}
.money-input input:hover, .money-input input:focus { border-bottom-color: var(--ink-3); outline: none; }
.line-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; }
.pctl { margin: 0; font-size: 13px; line-height: 1.3; color: var(--ink-2); min-width: 0; }
.pctl b { color: var(--ink); font-weight: 600; }
.job-pick {
  flex: none; max-width: 44%; font: 500 13px var(--sans); color: var(--ink);
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 3px; padding: 4px 6px;
}

/* Range: a ruled line filled in the person's colour up to the thumb (--fill set by JS). */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; margin: 6px 0 0; background: transparent; touch-action: pan-y; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--who) var(--fill, 0%), var(--rule) var(--fill, 0%)); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--rule); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--who); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -9px; border-radius: 50%; background: var(--who); border: 3px solid var(--paper); box-shadow: 0 0 0 1px var(--who); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--who); border: 3px solid var(--paper); box-shadow: 0 0 0 1px var(--who); }
input[type="range"]:focus-visible { outline-offset: 0; }

/* ---- Result ---- */
.result { padding: 26px 0 6px; }
/* Two lines that read as the sentence: "I make 1.9× / and pay 2.8×". Numbers are sized in proportion
   to their value (--k); rows keep a fixed height so nothing below shifts while dragging. */
.figures { display: grid; grid-template-columns: auto 1fr; grid-auto-rows: calc(var(--fig-max) * 1.02); column-gap: 14px; align-items: end; }
.figures .cap { font-size: 15px; color: var(--ink-2); white-space: nowrap; padding-bottom: calc(var(--fig-max) * 0.2); }
.figures .n {
  font-size: max(2.2rem, calc(var(--fig-max) * var(--k, 1)));
  line-height: calc(var(--fig-max) * 1.02); font-weight: 800; font-variation-settings: "wdth" 125; letter-spacing: -0.02em;
  white-space: nowrap; transition: font-size 0.18s ease-out;
}
.figures .n.tax { color: var(--red); }
.figures .n.inc { color: var(--hi, var(--ink)); }
.figures .cap.hi { color: var(--hi, var(--ink-2)); font-weight: 600; }
.figures .n i { font-style: normal; font-size: 0.55em; font-weight: 700; margin-left: 0.04em; }
@media (prefers-reduced-motion: reduce) { .figures .n { transition: none; } }

.verdict { font-size: 19px; line-height: 1.4; margin: 16px 0 18px; min-height: 2.8em; max-width: 40ch; }
.verdict b { font-weight: 700; }
.verdict .tax { color: var(--red); }

.pay-bars { margin: 0 0 18px; }
.pay-row { display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 10px; margin: 6px 0; }
.pay-row .who { font-size: 14px; color: var(--ink-2); }
.pay-track { height: 14px; }
.pay-bar { display: flex; height: 100%; gap: 2px; min-width: 2px; transition: width 0.18s ease-out; }
.pay-bar .keep { background: color-mix(in oklab, var(--who) 45%, var(--paper)); }
.pay-row.me { --who: var(--me); }
.pay-row.them { --who: var(--them); }
.pay-row .who { color: var(--who); font-weight: 600; }
.pay-bar .tax { background: var(--red); }
@media (prefers-reduced-motion: reduce) { .pay-bar { transition: none; } }
.pay-legend { margin: -10px 0 18px 58px; font-size: 12px; color: var(--ink-3); }
.pay-legend .swatch { display: inline-block; width: 10px; height: 10px; background: var(--red); vertical-align: -1px; margin-right: 2px; }

/* The book: ledger rows, a double rule under the tax line (bookkeeping total). */
.book { width: 100%; border-collapse: collapse; font-size: 15px; }
.book th, .book td { padding: 7px 0; border-bottom: 1px solid var(--rule); text-align: right; }
.book th { font-weight: 500; color: var(--ink-3); font-size: 13px; }
.book th:first-child, .book td:first-child { text-align: left; color: var(--ink-2); font-weight: 400; }
.book td { font-variation-settings: "wdth" 85; font-weight: 600; }
.book td + td { padding-left: 12px; width: 26%; }
.book tr.total td { border-bottom: 3px double var(--ink); }
.book tr.total td:not(:first-child) { color: var(--red); }
.book .me { color: var(--me); }
.book .them { color: var(--them); }
.book th.me, .book th.them { font-weight: 700; font-size: 14px; }
.book small { display: block; font-size: 12px; color: var(--ink-3); font-weight: 400; font-variation-settings: "wdth" 100; }

.scope { display: flex; align-items: center; gap: 10px; margin: 16px 0 0; flex-wrap: wrap; }
.scope-label { font-size: 13px; color: var(--ink-3); }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--ink-2); font: 500 13px var(--sans); padding: 5px 10px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--paper); }

/* ---- Notes, sources ---- */
.notes { padding: 22px 0 0; margin-top: 18px; border-top: 2px solid var(--ink); }
.fine { font-size: 13px; color: var(--ink-2); }
.job-note { margin: 0 0 12px; }
.table-view { margin: 8px 0; }
.table-view summary { cursor: pointer; font-size: 14px; font-weight: 600; padding: 4px 0; }
.table-scroll { overflow-x: auto; }
#job-table, #pctl-table { border-collapse: collapse; font-size: 12.5px; margin: 8px 0 14px; width: 100%; }
#job-table th, #job-table td, #pctl-table th, #pctl-table td { padding: 5px 8px; text-align: right; border-bottom: 1px solid var(--rule); white-space: nowrap; }
#job-table th:first-child, #job-table td:first-child, #pctl-table th:first-child, #pctl-table td:first-child { text-align: left; padding-left: 0; }
#job-table th, #pctl-table th { color: var(--ink-3); font-weight: 500; }

.foot { padding-top: 26px; padding-bottom: 56px; color: var(--ink-2); font-size: 14px; }
.foot h2 { font-size: 17px; font-weight: 700; color: var(--ink); margin: 18px 0 6px; font-variation-settings: "wdth" 112; }
.foot ul { padding-left: 18px; }
.foot li { margin-bottom: 8px; }

@media (max-width: 480px) {
  .top { padding-top: 22px; }
  .lede { font-size: 15px; }
  .ledger { margin-top: 16px; }
  .line { padding: 9px 0 11px; }
  .money-input { font-size: 30px; }
  .result { padding-top: 18px; }
  .figures { --fig-max: min(17vw, 7rem); }
  .verdict { font-size: 17px; margin: 12px 0 14px; min-height: 4.2em; }
}
