/* ThisCheck. Mobile first, one column, 16 px gutters, 16 px inputs (iOS doesn't zoom), one accent color, no red. */

:root {
  --bg: #f7f6f2;
  --card: #ffffff;
  --ink: #1d2422;
  --muted: #5b6662;
  --line: #d9dcd6;
  --accent: #0f6e66;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ee;
  --calm: #fff4dc;        /* short checks and notes: warm, never red */
  --calm-line: #e8cf94;
  --radius: 12px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141917;
    --card: #1d2422;
    --ink: #eef1ee;
    --muted: #a8b2ae;
    --line: #34403c;
    --accent: #5cc4b7;
    --accent-ink: #0b1513;
    --accent-soft: #1f3632;
    --calm: #33301f;
    --calm-line: #6b5d32;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

[hidden] { display: none !important; }
[tabindex="-1"]:focus { outline: none; }   /* headings get focus on a new screen, for screen readers */

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.wrap {
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

header.top {
  padding: 14px 0;
}
header.top a {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
}

h1 { font-size: 1.75rem; line-height: 1.2; margin: 0.5rem 0 0.75rem; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; line-height: 1.3; margin: 0 0 0.75rem; }
p { margin: 0 0 0.75rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

a { color: var(--accent); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--gutter);
  margin: 0 0 var(--gutter);
}

.steps {
  display: flex;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0 0 var(--gutter);
  font-size: 0.8125rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.steps li { padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); }
.steps li[aria-current="step"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Form pieces */
fieldset { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
legend, .label { display: block; font-weight: 600; margin: 0 0 8px; padding: 0; }
.hint { display: block; font-size: 0.875rem; color: var(--muted); margin: -4px 0 8px; }

input[type="text"], input[type="date"], input[type="number"], input[type="email"], select {
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  min-height: 44px;
}
input:focus-visible, button:focus-visible, .pill input:focus-visible + span {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.money { position: relative; }
.money::before {
  content: "$";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}
.money input { padding-left: 26px; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Radio groups that look like buttons */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pills.stack { flex-direction: column; }
.pill { position: relative; }
.pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill span {
  display: inline-block;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
}
.pills.stack .pill span { border-radius: 10px; width: 100%; }
.pill input:checked + span {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  font-weight: 600;
}

.error { display: block; color: var(--ink); background: var(--calm); border-left: 4px solid var(--calm-line);
  padding: 6px 10px; border-radius: 6px; margin-top: 8px; font-size: 0.9375rem; }

.echo { background: var(--accent-soft); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 20px; }
.echo p:last-child { margin-bottom: 0; }
.echo .note { font-size: 0.9375rem; color: var(--muted); }

.notice { background: var(--calm); border: 1px solid var(--calm-line); border-radius: var(--radius);
  padding: 12px 14px; margin: 0 0 var(--gutter); }

button, .button {
  font: inherit;
  font-weight: 600;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
button.wide, .button.wide { width: 100%; }
button.quiet { background: transparent; color: var(--accent); border-color: transparent; padding: 8px 10px; min-height: 40px; }
button.secondary { background: transparent; color: var(--accent); }

.summary { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.summary p { margin: 0; }

ul.trust { list-style: none; padding: 0; margin: 16px 0; }
ul.trust li { padding: 4px 0 4px 26px; position: relative; }
ul.trust li::before { content: "✓"; position: absolute; left: 4px; color: var(--accent); font-weight: 700; }

.example dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0 0 12px; }
.example dt { color: var(--muted); }
.example dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.example .big { font-size: 1.375rem; font-weight: 700; }

footer.legal { padding: 24px 0 40px; font-size: 0.8125rem; color: var(--muted); }

/* Steps you can go back to */
.steps li button { font: inherit; background: none; border: 0; color: var(--accent); padding: 0; min-height: 0; cursor: pointer; text-decoration: underline; }

/* Chips that add a row */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 var(--gutter); }
button.chip { min-height: 40px; padding: 6px 12px; font-weight: 500; background: var(--card); color: var(--ink); border: 1px dashed var(--line); }
button.chip:hover { border-color: var(--accent); }

/* Rows: tap to edit */
ul.rows { list-style: none; padding: 0; margin: 0 0 var(--gutter); }
ul.rows li { margin: 0 0 8px; }
button.row {
  width: 100%; text-align: left; display: flex; flex-direction: column; gap: 2px;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; font-weight: 400; min-height: 56px;
}
button.row:hover { border-color: var(--accent); }
.row-name { font-weight: 600; overflow-wrap: anywhere; }
.row-sub { font-size: 0.9375rem; color: var(--muted); }

/* The inline editor */
form.editor { border-color: var(--accent); }
form.editor h3 { margin: 0 0 12px; font-size: 1.0625rem; }
.field { margin: 0 0 16px; }
input.short { max-width: 8rem; }
.percent { position: relative; max-width: 10rem; }
.percent::after { content: "%"; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.percent input { padding-right: 30px; }
label.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
label.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.hint.indent { margin: 4px 0 0 32px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions button { min-height: 44px; padding: 10px 18px; }
.actions .delete { margin-left: auto; }

.totals { font-weight: 600; }
.nav { display: flex; gap: 12px; margin: 24px 0 8px; }
.nav button:last-child { flex: 1; }

/* "Rent removed. Undo" */
.toast {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(32rem, calc(100% - 32px));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--ink); color: var(--bg); border-radius: var(--radius); padding: 8px 8px 8px 16px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.2);
}
.toast button.quiet { color: var(--bg); text-decoration: underline; }

/* ---------- Your plan ---------- */
.plan h2 { margin: 32px 0 12px; scroll-margin-top: 12px; }
.summary-line { font-weight: 600; font-size: 1.0625rem; }
.note { background: var(--calm); border-left: 4px solid var(--calm-line); border-radius: 6px; padding: 8px 12px; }

article.check {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--gutter); margin: 0 0 var(--gutter);
}
article.check.short { border-color: var(--calm-line); }
article.check header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 0 0 8px; }
article.check h3 { margin: 0; font-size: 1.125rem; }

ul.covers { list-style: none; padding: 0; margin: 0 0 8px; }
ul.covers li {
  display: grid; grid-template-columns: 1fr auto; column-gap: 12px;
  padding: 4px 0; border-bottom: 1px dashed var(--line);
}
.cover-name { overflow-wrap: anywhere; }
.cover-due { grid-row: 2; font-size: 0.8125rem; color: var(--muted); }
.cover-amount { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-variant-numeric: tabular-nums; }

dl.lines { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 8px 0 12px; }
dl.lines dt { color: var(--muted); }
dl.lines dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.yours { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin: 0 0 8px; }
article.check.short .yours { background: var(--calm); }
.yours p { margin: 0; }
.yours-label { font-weight: 600; }
.yours-amount { font-size: 2rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

ul.three { padding-left: 20px; color: var(--muted); }

.evenout .proposal, .evenout .tried { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--gutter); margin: 0 0 12px; }
.evenout .proposal { border-color: var(--accent); }
.evenout .proposal p:last-child { margin: 10px 0 0; }

ul.checklist { list-style: none; padding: 0; margin: 0 0 8px; }
ul.checklist li { position: relative; padding: 10px 0 10px 34px; border-bottom: 1px solid var(--line); }
ul.checklist li::before {
  content: ""; position: absolute; left: 2px; top: 12px; width: 20px; height: 20px;
  border: 2px solid var(--accent); border-radius: 4px;
}

.save-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.save-actions button:first-child { flex: 1 1 100%; }
.save-actions button.secondary { flex: 1; }
.manual-copy input { margin: 0 0 12px; }

details.year { margin: 32px 0 0; }
details.year summary { cursor: pointer; font-weight: 600; padding: 8px 0; color: var(--accent); }
.table-wrap { overflow-x: auto; }
details.year table { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
details.year th, details.year td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
details.year .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
details.year tr.short td:last-child { font-weight: 700; }
details.year tbody th { white-space: nowrap; font-weight: 600; }

/* ---------- Print / Save as PDF: the plan on paper ---------- */
@media print {
  :root { --bg: #fff; --card: #fff; --ink: #000; --muted: #333; --line: #999; --accent: #000; --accent-soft: #fff; --calm: #fff; --calm-line: #666; }
  body { font-size: 11pt; background: #fff; }
  .wrap { max-width: none; padding: 0; }
  header.top a { font-size: 14pt; }
  .steps, .nav, .toast, button, .no-print, .evenout .muted.small { display: none !important; }
  .plan h2 { margin: 18pt 0 6pt; break-after: avoid; }
  article.check, .card, .evenout .proposal, .evenout .tried, ul.checklist li { break-inside: avoid; }
  .yours-amount { font-size: 18pt; }
  details.year summary { color: #000; }
  a { color: #000; }
}

/* Header link, settings */
header.top { display: flex; justify-content: space-between; align-items: center; }
button.header-link { min-height: 40px; padding: 6px 4px; font-weight: 500; }
.notice p:last-child { margin-bottom: 0; }
.notice button { margin-top: 10px; }
.notice.confirm .actions { margin-top: 10px; }
label.button.secondary { background: transparent; color: var(--accent); font-weight: 600; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
ul.math { padding-left: 20px; }
ul.math li { margin: 0 0 8px; }
dl.faq dt { font-weight: 600; margin-top: 12px; }
dl.faq dd { margin: 4px 0 0; }
select { appearance: auto; }
@media print { button.header-link { display: none; } }
.settings h2 { margin: 32px 0 12px; }
.settings h1 + h2 { margin-top: 8px; }
