/* Chore Chart. The app is a desk with one sheet of paper on it: the
   chrome (bar, popovers) follows light and dark, the paper stays paper. */

@font-face {
  font-family: "Archivo Chart";
  src: url("fonts/Archivo-Heavy.woff2") format("woff2");
  font-weight: 700 900;
  font-display: block;
}

:root {
  --desk: #e8e3d8;
  --bar-bg: rgba(246, 243, 236, 0.88);
  --panel: #fbfaf6;
  --text: #24221f;
  --muted: #6b665d;
  --line: #d3ccbe;
  --hover: rgba(36, 34, 31, 0.06);
  --accent: #d2452b;
  --accent-ink: #b8361e;
  --paper: #fffefb;
  --print-bg: #24221f;
  --print-fg: #fffdf8;
  --display: "Archivo Chart", "Arial Black", system-ui, sans-serif;
  --ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --desk: #1c1b19;
    --bar-bg: rgba(36, 34, 31, 0.9);
    --panel: #2a2825;
    --text: #ece8e0;
    --muted: #a8a196;
    --line: #45413a;
    --hover: rgba(236, 232, 224, 0.08);
    --accent: #ec6a4f;
    --accent-ink: #f08a73;
    --paper: #2f2c28;
    --print-bg: #f2eee6;
    --print-fg: #1c1b19;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--desk); scroll-padding-top: calc(var(--bar-h, 64px) + 16px); scroll-padding-bottom: calc(var(--random-nav-h, 0px) + 16px); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--desk);
  color: var(--text);
  font: 15px/1.45 var(--ui);
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.35; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg.ic { width: 1em; height: 1em; display: block; }

/* ------------------------------------------------------------------ bar */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bar-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.chip, .print-btn, .icon-btn, .month-label, .view-toggle button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  padding: 0 12px;
  white-space: nowrap;
}
.chip svg, .print-btn svg { width: 16px; height: 16px; flex: none; }
.chip:hover, .icon-btn:hover, .month-label:hover { background: var(--hover); }
.chip[aria-expanded="true"] { background: var(--hover); border-color: var(--line); }

.charts-btn { padding-left: 8px; min-width: 0; text-align: left; }
.charts-btn .mark { width: 28px; height: 28px; }
.charts-btn .caret { width: 12px; height: 12px; opacity: 0.6; }
.chip-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.app-name { font: 800 11px/1.1 var(--display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.chart-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; max-width: 22ch; }

.month-step { display: flex; align-items: center; gap: 2px; margin: 0 auto; }
.icon-btn { padding: 0; width: 38px; justify-content: center; }
.icon-btn svg { width: 16px; height: 16px; }
.month-label { font: 800 15px/1 var(--display); letter-spacing: 0.01em; min-width: 11.5em; justify-content: center; }
.month-label:not(.is-now)::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.bar-actions { display: flex; align-items: center; gap: 4px; }
.print-btn {
  margin-left: 6px;
  background: var(--print-bg);
  color: var(--print-fg);
  font-weight: 600;
  padding: 0 16px;
}
.print-btn:hover { filter: brightness(1.15); }
.print-btn svg { --accent: #ec6a4f; }

.view-toggle { display: none; padding: 2px; border: 1px solid var(--line); border-radius: 11px; }
.view-toggle button { min-height: 40px; padding: 0 12px; border-radius: 8px; font-size: 14px; }
.view-toggle button[aria-pressed="true"] { background: var(--text); color: var(--desk); }

@media (max-width: 1020px) {
  .month-label { min-width: 9.5em; }
  .chart-name { max-width: 14ch; }
}
@media (max-width: 900px) {
  .chip.tool { padding: 0 9px; }
}
/* Phones: the chart switcher and Print on the first row, the month on the
   second, the view toggle and the three tools on the third. */
@media (max-width: 759px) {
  .bar { display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 6px 4px; padding: 8px 12px; }
  .bar-actions { display: contents; }
  .view-toggle { display: flex; }
  .month-step { justify-content: space-between; margin: 0; }
  .month-label { flex: 1; min-width: 0; }
  .print-btn { margin-left: 0; }
  .charts-btn { grid-column: 1 / 5; grid-row: 1; justify-self: start; max-width: 100%; }
  .print-btn { grid-column: 5; grid-row: 1; }
  .month-step { grid-column: 1 / -1; grid-row: 2; }
  .view-toggle { grid-column: 1; grid-row: 3; margin: 0; }
  #addBtn { grid-column: 3; grid-row: 3; }
  #setupBtn { grid-column: 4; grid-row: 3; }
  #shareBtn { grid-column: 5; grid-row: 3; }
  /* the tools keep a short label under their icon */
  .chip.tool { flex-direction: column; justify-content: center; gap: 2px; min-height: 46px; min-width: 52px; padding: 2px 6px; font-size: 11.5px; line-height: 1; }
}

.banner, .overfull {
  max-width: 760px;
  margin: 14px auto 0;
  padding: 12px 16px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px 16px;
  flex-wrap: wrap;
}
.banner { background: var(--panel); border: 1px solid var(--line); }
.banner p { margin: 0; flex: 1 1 260px; }
.banner-actions { display: flex; gap: 8px; }
.overfull { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text); font-size: 14px; }
@media (max-width: 759px) {
  .banner, .overfull { margin: 10px 12px 0; }
}

/* -------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-weight: 500;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--print-bg); color: var(--print-fg); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.15); }
.btn.danger { color: var(--accent-ink); }

/* ------------------------------------------------------------- popovers */

.pop {
  position: fixed;
  inset: auto;
  margin: 0;
  width: min(340px, calc(100vw - 16px));
  max-height: calc(100vh - 90px);
  overflow: auto;
  padding: 6px 16px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
}
.pop.no-api { display: none; z-index: 40; }
.pop.no-api.open { display: block; }
.pop h3 {
  margin: 14px 0 8px;
  font: 800 11px/1.2 var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.pop-hint { margin: -4px 0 10px; font-size: 13px; color: var(--muted); }
.seg + .pop-hint { margin: 8px 0 0; }
.pop-row { display: flex; gap: 8px; margin-top: 10px; }
.pop-row .btn { flex: 1; }
.pop-col { display: grid; gap: 8px; }

@media (max-width: 639px) {
  .pop {
    left: 0 !important;
    right: 0;
    top: auto !important;
    bottom: var(--random-nav-h, 0px);
    width: 100%;
    max-height: 75vh;
    border-radius: 18px 18px 0 0;
    padding-bottom: 20px;
  }
  .pop::backdrop { background: rgba(0, 0, 0, 0.25); }
}

.pop-label { margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
@media (min-width: 640px) { .sec-pop { width: min(300px, calc(100vw - 16px)); } }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper .btn { width: 44px; padding: 0; }
.stepper .btn svg { width: 16px; height: 16px; }
.stepper-n { min-width: 2.5em; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.menu-acts { margin-top: 14px; gap: 2px; }
.menu-item { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 10px; border: 0; border-radius: 9px; background: none; text-align: left; }
.menu-item svg { width: 16px; height: 16px; }
.menu-item:hover:not(:disabled) { background: var(--hover); }
.menu-item.danger { color: var(--accent-ink); }
.new-row { margin: 12px 0 2px; }

.seg { display: flex; padding: 3px; border-radius: 11px; background: var(--hover); }
.seg button {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: 14px;
  white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--panel); box-shadow: 0 0 0 1.5px var(--text); font-weight: 700; }

.inks { display: flex; gap: 10px; flex-wrap: wrap; }
.ink {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--panel);
  background: var(--sw);
  box-shadow: 0 0 0 1px var(--line);
}
.ink[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text); }
.ink-hint { margin: 10px 0 0; }
.ink-hint:empty { display: none; }

.chart-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 40vh; overflow: auto; }
.chart-row {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  align-items: center;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
}
.chart-row:hover { background: var(--hover); }
.chart-row[aria-current="true"] { background: var(--hover); box-shadow: inset 0 0 0 1px var(--line); }
.cr-ink { grid-row: span 2; width: 12px; height: 12px; border-radius: 3px; }
.cr-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-meta { font-size: 12.5px; color: var(--muted); }

.starters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.starter, .kind {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: none;
}
.starter:hover, .kind:hover { background: var(--hover); }
.starter span, .kind-t span { font-size: 12.5px; color: var(--muted); line-height: 1.3; }

.kinds { display: grid; gap: 8px; }
.kind { flex-direction: row; align-items: center; gap: 12px; }
.kind-pic { width: 34px; height: 34px; flex: none; padding: 5px; border-radius: 8px; background: var(--paper); border: 1px solid var(--line); }
.kind-t { display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--random-nav-h, 0px));
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 24px);
  padding: 10px 12px 10px 16px;
  border-radius: 12px;
  background: var(--print-bg);
  color: var(--print-fg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-btn {
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.16);
  font-weight: 600;
  color: inherit;
}

/* ----------------------------------------------------------------- desk */

.desk {
  overflow-anchor: none;
  display: flex;
  justify-content: center;
  padding: 32px 16px 56px;
  overflow-x: hidden;
}
.stage { position: relative; flex: none; }
body.flow .desk { padding: 12px 12px 40px; }
body.flow .stage { width: 100%; max-width: 640px; }

/* ---------------------------------------------------------------- paper */

.sheet {
  --u: 11px;
  --ink: #d2452b;
  --type: #1f1e1b;
  /* the paper's greys, each mixed with a little of the chart's accent
     color (--ink), so a blue chart has blue-greys, a green one green */
  --soft: color-mix(in oklab, var(--ink) 22%, #57524a);
  --faint: color-mix(in oklab, var(--ink) 22%, #635d54);
  --rule: color-mix(in oklab, var(--ink) 18%, #cfc8bb);
  --edge: color-mix(in oklab, var(--ink) 22%, #888275);
  --tint: color-mix(in oklab, var(--ink) 7%, #f5f2ec);
  --na: color-mix(in oklab, var(--ink) 10%, #e9e5dc);
  --na-line: color-mix(in oklab, var(--ink) 22%, #9a9387);
  /* zebra bands on rows that run across the page */
  --stripe: color-mix(in oklab, var(--ink) 3%, #faf8f4);
  font-family: var(--ui);
  font-size: var(--u);
  line-height: 1.3;
  color: var(--type);
  background: #fff;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  color-scheme: light;
}
.sheet.is-page {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--pw);
  height: var(--ph);
  padding: 0.42in 0.46in 0.4in;
  transform-origin: 0 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 12px 40px rgba(40, 30, 10, 0.16);
}
.sheet.is-flow {
  --u: 15px;
  padding: 20px 18px 26px 26px;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 8px 26px rgba(40, 30, 10, 0.14);
}
.sheet-in { display: flex; flex-direction: column; gap: 1.7em; }
.is-page .sheet-in { height: 100%; }
.sec { position: relative; flex: none; }

/* header: the month, big, in the chart's ink; its name on the right */
.sh-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5em 1.5em;
  flex-wrap: wrap;
  padding-bottom: 0.55em;
  border-bottom: 0.3em solid var(--ink);
}
.sh-month { order: -1; display: flex; align-items: baseline; gap: 0.3em; font: 900 3.6em/0.85 var(--display); color: var(--ink); letter-spacing: -0.01em; }
.sh-y { color: var(--soft); opacity: 0.6; font-size: 0.55em; }
.sh-cont { font: italic 400 0.3em/1 var(--ui); color: var(--soft); letter-spacing: 0; align-self: center; }
.sh-name { font: 800 1.15em/1.1 var(--display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--type); padding-bottom: 0.15em; max-width: 50%; text-align: right; overflow-wrap: anywhere; }
.is-flow .sh-name { max-width: none; text-align: left; }
.is-flow .sh-month { font-size: 2.6em; }

/* section headings */
.sec-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.25em 0.7em; margin-bottom: 0.7em; }
.sec-head::before {
  content: "";
  align-self: center;
  width: 0.6em;
  height: 0.6em;
  border-radius: 0.14em;
  background: var(--ink);
  flex: none;
}
.sec-h { margin: 0; font: 800 1.4em/1.1 var(--display); letter-spacing: 0.005em; overflow-wrap: anywhere; }
.sec-cont { font-style: italic; color: var(--soft); }
.sec-note { font-style: italic; color: var(--soft); }

/* a tick box */
.box {
  display: block;
  position: relative;
  border: max(1px, 0.085em) solid var(--edge);
  border-radius: 0.22em;
  background: #fff;
}
.box.we { background: var(--tint); }
/* a day already gone when the sheet was printed: greyed and struck through,
   so it reads as not applicable rather than missed */
.box.na { border-color: var(--rule); background: var(--na); }
/* the slash: one line corner to corner, the same weight in every box (a
   gradient's hard edges fall between pixels and print at 1 or 2) */
.box.na::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 138%;
  height: 0;
  border-top: max(1px, 0.1em) solid var(--na-line);
  transform: translate(-50%, -50%) rotate(-45deg);
}
.box.na i { color: var(--na-line); }

/* Black: made for a black-and-white printer, which turns light greys into
   speckle and drops faint lines. Solid black and a few dark greys only, no
   shaded fills: weekends show in bold letters and a heavier box, a day
   already gone is a black slash on white. */
.sheet.bw {
  --type: #000;
  --soft: #333;
  --faint: #444;
  --rule: #7a7a7a;
  --edge: #222;
  --tint: #fff;
  --na: #fff;
  --na-line: #222;
}
.sheet.bw .box.we { border-width: max(1.5px, 0.14em); }
/* (no bands for a black-and-white printer, which would speckle them: a
   rule under every row instead) */
.sheet.bw .strip > .item, .sheet.bw .wk > .item { background: none; box-shadow: none; }
.sheet.bw .strip > .item { padding-bottom: 0.16em; border-bottom: 1px solid #b4b4b4; }
.sheet.bw .wk > .item { border-bottom-color: #b4b4b4; }
.sheet.bw :is(.st-day.we, .cal .dow.we) { font-weight: 800; }
.sheet.bw .st-day.we b, .sheet.bw .cal .dow.we { color: #000; }
.sheet.bw .box.na { border-style: solid; }
.sheet.bw .sh-y { color: #555; opacity: 1; }
.box i {
  position: absolute;
  top: 0.18em;
  left: 0.24em;
  font: normal 0.52em/1 var(--ui);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* blank rows: a line to write a chore on */
.item.spare :is(.st-name, .card-name, .wk-name, .mo-name) {
  align-self: end;
  min-height: 1.3em;
  border-bottom: 1px solid var(--rule);
}

/* daily, as rows: a box for every day of the month */
.strip { display: grid; gap: 0.32em; }
.st-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(7em, 21%) repeat(var(--n), minmax(0, 1fr));
  column-gap: 0.16em;
  align-items: center;
}
.st-name { padding-right: 0.7em; line-height: 1.2; font-weight: 500; overflow-wrap: anywhere; }

/* Every other chore in a row-per-chore layout sits on a faint band, so the
   eye can follow its name across to its boxes. The band reaches a little
   past the row (shadows, which don't widen the page the fit measures) and
   fills half the gap above and below; the boxes stay white. */
.strip > .item:nth-child(odd),
.wk > .item:nth-child(odd) {
  background: var(--stripe);
  border-radius: 0.25em;
  box-shadow: -0.35em 0 0 0.16em var(--stripe), 0.35em 0 0 0.16em var(--stripe);
}
.wk > .item:nth-child(odd) { box-shadow: -0.35em 0 0 0 var(--stripe), 0.35em 0 0 0 var(--stripe); }
.item.ghost { background: none !important; box-shadow: none !important; }
/* boxes scale with the type, so a long list still fits */
.st-row .box { width: 100%; max-width: 1.75em; aspect-ratio: 1; justify-self: center; }
.st-top { align-items: end; }
.st-day { display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.st-day b { font-size: 0.62em; font-weight: 600; color: var(--faint); }
.st-day i { font-style: normal; font-size: 0.72em; color: var(--soft); font-variant-numeric: tabular-nums; }
.st-day.we b, .st-day.we i { color: var(--ink); }

/* daily, as cards: a little calendar per chore */
.cards { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 1.2em 2em; }
.cols-1 .cards { --cols: 1; }
.cols-3 .cards { --cols: 3; gap: 1.1em 1.6em; }
.card { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.3em 1em; align-items: start; }
.card-name { padding-top: 1.05em; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.cols-3 .card { grid-template-columns: minmax(0, 1fr); }
.cols-3 .card-name { padding-top: 0; }
.cal {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 2.6em));
  gap: 0.2em;
}
.cal .box { aspect-ratio: 1; }
.cal .box i { font-size: 0.62em; }
.cols-3 .cal { width: 100%; }
.cal .dow { font-size: 0.62em; font-weight: 600; text-align: center; color: var(--faint); line-height: 1.2; }
.cal .dow.we { color: var(--ink); }
.cal .box.out { border-color: transparent; background: none; }
.item.spare .cal .box { border-style: dashed; }
.card.spare .card-name { padding-top: 0; margin-top: 1.05em; }
.cols-3 .card.spare .card-name { margin-top: 0; }

/* weekly: chores down, weeks across */
.wk { display: grid; }
.wk-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(8em, 1fr) repeat(var(--n), minmax(3.6em, 5.4em));
  column-gap: 0.5em;
  align-items: center;
  min-height: 2.1em;
  border-bottom: 1px solid var(--tint);
}
.wk-row:last-child { border-bottom: 0; }
/* A blank row's write-in line is its own rule wherever rows already have
   one (the weekly table; every row-per-chore layout in Black), rather than
   a second line just above it. */
.wk > .item.spare { border-bottom: 1px solid var(--rule); }
.wk > .item.spare .wk-name,
.sheet.bw .strip > .item.spare .st-name { border-bottom: 0; }
.wk-top { min-height: 0; padding-bottom: 0.3em; border-bottom: 1px solid var(--rule); }
.wk-name { font-weight: 500; line-height: 1.2; padding: 0.2em 0; overflow-wrap: anywhere; }
.wk-h { display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.wk-h b { font-size: 0.66em; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--soft); }
.wk-h i { font-style: normal; font-size: 0.72em; color: var(--faint); font-variant-numeric: tabular-nums; }
.wk-c { display: flex; justify-content: center; }
.wk-c .box { width: 1.45em; height: 1.45em; }

/* monthly: a checklist in columns */
.mo { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows, 1), auto); grid-auto-flow: column; gap: 0.45em 2em; }
.cols-1 .mo { --cols: 1; }
.cols-3 .mo { --cols: 3; }
.mo-row { position: relative; display: flex; align-items: center; gap: 0.65em; min-height: 1.75em; }
.mo-row .box { flex: none; width: 1.35em; height: 1.35em; }
.mo-name { flex: 1; min-width: 0; line-height: 1.25; font-weight: 500; overflow-wrap: anywhere; }

/* notes: ruled lines that take the rest of the page */
.sec-notes { display: flex; flex-direction: column; }
.is-page .sec-notes { flex: 1 1 auto; min-height: 6.5em; }
.lines { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 2.2em; flex: 1 1 auto; min-height: 4.4em; }
.cols-1 .lines { --cols: 1; }
.is-flow .lines { min-height: 13em; }
/* (ruled with real lines, not a gradient, which some printers print as a
   solid black block; held out of the layout, so they fill the space the
   notes are given and no more) */
.lines-col { position: relative; overflow: hidden; }
.lines-in { position: absolute; inset: 0; }
.lines-in > i { display: block; height: 2.2em; border-bottom: 1px solid var(--rule); }

/* ------------------------------------------------- editing on the paper */

.sheet [contenteditable] { outline: none; border-radius: 0.15em; cursor: text; }
.sheet [contenteditable]:hover { background: rgba(0, 0, 0, 0.035); }
.sheet [contenteditable]:focus { background: color-mix(in srgb, var(--ink) 9%, transparent); outline: calc(2px / var(--scale, 1)) solid var(--ink); outline-offset: 0.1em; }
.sheet [contenteditable]:empty { display: inline-block; min-width: 5em; }
.sheet .sec-note[contenteditable]:empty { min-width: 2em; }
.sheet [data-ph]:empty::before { content: attr(data-ph); color: var(--faint); font-style: italic; font-weight: 400; }
.sheet .sh-name[data-ph]:empty::before, .sheet .sec-title[data-ph]:empty::before { font-family: var(--display); font-style: normal; font-weight: 800; color: var(--faint); }
.sheet .sec-note[data-ph]:empty::before { opacity: 0; }
.sheet .sec:hover .sec-note[data-ph]:empty::before, .sheet .sec.is-active .sec-note[data-ph]:empty::before { opacity: 1; }
.is-flow .sec-note[data-ph]:empty::before { opacity: 1; }

/* the editor's own controls on the paper keep a fixed size, whatever the
   paper's scale (--k is one screen pixel) */
.sec-more, .del, .grip { --k: calc(1px / var(--scale, 1)); }

/* ⋯ beside a section's title: its options */
.sec-more {
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(30 * var(--k));
  height: calc(26 * var(--k));
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: calc(8 * var(--k));
  background: none;
  color: var(--soft);
  opacity: 0.55;
}
.sec-more svg { width: calc(18 * var(--k)); height: calc(18 * var(--k)); }
.sec:hover .sec-more, .sec-more:focus-visible, .sec-more[aria-expanded="true"] { opacity: 1; background: rgba(0, 0, 0, 0.06); color: var(--type); }
.sec-more:focus-visible { outline: calc(2px / var(--scale, 1)) solid var(--ink); outline-offset: 0; }
.is-flow .sec-more { width: 40px; height: 40px; opacity: 0.8; }
.is-flow .sec-more svg { width: 20px; height: 20px; }

/* × at a chore's right edge, in the page's margin */
.del {
  position: absolute;
  right: calc(-24 * var(--k));
  top: 50%;
  width: calc(20 * var(--k));
  height: calc(20 * var(--k));
  margin-top: calc(-10 * var(--k));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--soft);
  opacity: 0;
  transition: opacity 0.12s;
}
.del svg { width: calc(13 * var(--k)); height: calc(13 * var(--k)); }
.del:hover { background: #fbe4df; color: #b8361e; }
.item:hover > .del, .item:focus-within > .del { opacity: 1; }
.del:focus-visible { opacity: 1; outline: calc(2px / var(--scale, 1)) solid var(--ink); }
.card > .del { top: 0.65em; }
.cols-2 .card > .del, .cols-3 .card > .del { right: calc(-20 * var(--k)); }
/* touch screens delete with a swipe, so the × stays out of the way */
@media (hover: none) { .del:not(:focus-visible) { opacity: 0; pointer-events: none; } }

/* swipe a chore left to delete it */
.sheet .item { touch-action: pan-y; }
.item.swiping { transform: translateX(var(--swipe, 0)); background: #fff; transition: none; z-index: 2; box-shadow: 0.6em 0 0 0 #fff; }
.item.swiping::after {
  content: "Delete";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 100%;
  width: 9em;
  display: flex;
  align-items: center;
  padding-left: 1em;
  background: #e9e4da;
  color: var(--soft);
  font: 600 0.95em/1 var(--ui);
}
.item.swipe-armed::after { background: #c53d24; color: #fff; }

/* drag a chore by its grip */
.grip {
  --k: calc(1px / var(--scale, 1));
  position: absolute;
  left: calc(-19 * var(--k));
  top: 50%;
  width: calc(16 * var(--k));
  height: calc(22 * var(--k));
  margin-top: calc(-11 * var(--k));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  cursor: grab;
  touch-action: none;
  opacity: 0;
  transition: opacity 0.12s;
}
.grip svg { width: 100%; height: 100%; }
.card > .grip { top: 0.65em; margin-top: calc(-11 * var(--k)); }
.item:hover > .grip, .grip:active { opacity: 1; }
.is-flow .grip { opacity: 0.5; left: -24px; width: 22px; height: 32px; margin-top: -16px; }
@media (hover: none) {
  .is-page .grip { display: none; }
  .is-flow .grip { opacity: 0.55; }
}
.item.dragging { opacity: 0.4; }
.item.drop-before { box-shadow: 0 -0.2em 0 0 var(--ink); }
.item.drop-after { box-shadow: 0 0.2em 0 0 var(--ink); }
.sec.flash { animation: flash 0.9s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--ink) 14%, transparent); } to { background: transparent; } }

.empty-sheet { margin: 4em auto; max-width: 28em; text-align: center; color: var(--soft); font-size: 1.15em; }
.empty-sheet .btn { margin-top: 0.8em; font-size: 15px; }

/* measuring the fit: the editor's own bits don't count */
.measuring .sec-more, .measuring .grip, .measuring .del { display: none; }
.measuring .item.ghost { display: none; }
.measuring [data-ph]:empty::before { content: none; }
.measuring .sec.flash { animation: none; }

/* ---------------------------------------------------------------- print */

/* The print copies are laid out (to be fitted) but kept off screen. */
.print-root { position: absolute; left: -10000px; top: 0; visibility: hidden; }
.print-root .sheet.is-page { position: relative; height: calc(var(--ph) - 0.02in); box-shadow: none; }

@media print {
  html, body { background: #fff !important; margin: 0 !important; padding: 0 !important; min-height: 0; }
  body > :not(.print-root) { display: none !important; }
  .print-root { position: static; visibility: visible; }
  .print-root .sheet { break-after: page; break-inside: avoid; }
  .print-root .sheet:last-child { break-after: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .toast, .grip, .del { transition: none !important; }
  .sec.flash { animation: none !important; }
}

/* phones: the weekly table narrows to fit */
.is-flow .wk-row { grid-template-columns: minmax(6em, 1fr) repeat(var(--n), 2.3em); column-gap: 0.3em; }
.is-flow .wk-h b { font-size: 0.5em; letter-spacing: 0.02em; }
.is-flow .wk-h i { font-size: 0.62em; }
.is-flow .card { grid-template-columns: minmax(0, 1fr); }
.is-flow .card-name { padding-top: 0; }
.is-flow .card.spare .card-name { margin-top: 0; }
.is-flow .cal { grid-template-columns: repeat(7, minmax(0, 2.3em)); grid-auto-rows: auto; }
.is-flow .cal .box { aspect-ratio: 1; }
.is-flow .cards { gap: 1.4em; }

/* --------------------------------------------------------------- splash */

.splash-layer {
  position: fixed;
  inset: 0 0 var(--random-nav-h, 0px);
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.splash-scrim { position: fixed; inset: 0 0 var(--random-nav-h, 0px); background: rgba(28, 27, 25, 0.45); }
.splash {
  position: relative;
  width: min(880px, 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
}
.splash-in { position: relative; padding: 24px 24px 26px; }
.splash h2 { margin: 0 44px 4px 0; font: 900 26px/1.1 var(--display); }
.splash-sub { margin: 0 0 18px; color: var(--muted); }
.splash-x { position: absolute; top: 14px; right: 14px; width: 40px; min-height: 40px; }
.presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.preset {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: none;
  text-align: left;
}
.preset:hover { background: var(--hover); }
.preset.is-default { border: 2px solid var(--text); padding: 9px 9px 11px; }
.preset-pic {
  position: relative;
  display: block;
  aspect-ratio: 8.5 / 11;
  width: min(100%, 158px);
  align-self: center;
  overflow: hidden;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08), 0 4px 14px rgba(40, 30, 10, 0.12);
}
.preset-pic .sheet { box-shadow: none; }
.preset-t { display: flex; flex-direction: column; gap: 1px; line-height: 1.25; }
.preset-t b { font: 800 15px/1.2 var(--display); }
.preset-t span { font-size: 13.5px; color: var(--muted); }
.preset-t em { margin-top: 3px; font-size: 12px; font-style: normal; color: var(--accent-ink); }
@media (max-width: 639px) {
  .splash-layer { place-items: end stretch; padding: 24px 0 0; }
  .splash { width: 100%; border-radius: 18px 18px 0 0; }
  .splash-in { padding: 18px 14px 20px; }
  .splash h2 { font-size: 22px; }
  .presets { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .preset-pic { width: min(100%, 132px); }
}

.nav-probe { position: fixed; left: 0; bottom: 0; width: 0; height: var(--random-nav-h, 0px); visibility: hidden; pointer-events: none; }
