:root {
  color-scheme: light dark;
  --bg: #fdfaf6;
  --fg: #1e1b18;
  --muted: #6b625a;
  --card: #ffffff;
  --line: #e7ded3;
  --accent: #a2542a;
  --accent-fg: #ffffff;
  --soft: #f6efe6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17151a;
    --fg: #f2ede7;
    --muted: #a89f96;
    --card: #201d23;
    --line: #37323a;
    --accent: #e8a06a;
    --accent-fg: #241a12;
    --soft: #26222b;
  }
}

* { box-sizing: border-box; }

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

main { max-width: 72rem; margin: 0 auto; padding: 1rem 1rem 2rem; }

h1 { font-size: 1.9rem; margin: 0 0 0.35rem; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 0 0 0.6rem; }
h3 { font-size: 1rem; margin: 0 0 0.4rem; }

.hero { padding: 0.5rem 0 1rem; }
.lead { margin: 0 0 0.4rem; max-width: 46rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.layout { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }

@media (min-width: 60rem) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .sheet-col { position: sticky; top: 1rem; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem 1rem;
  margin-bottom: 1rem;
}

.grid { display: grid; gap: 0.6rem; grid-template-columns: 1fr; }
@media (min-width: 34rem) {
  .grid { grid-template-columns: 1fr 1fr; }
  .field.wide { grid-column: 1 / -1; }
}
@media print { .grid { display: none; } }

.field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }

label { font-size: 0.82rem; font-weight: 600; color: var(--muted); }

input, textarea, button { font: inherit; }

input, textarea {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  width: 100%;
  min-width: 0;
}

textarea { resize: vertical; }

input:focus-visible, textarea:focus-visible, button:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
}

button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.ghost { background: transparent; }
button:hover { filter: brightness(1.06); }
button:disabled { cursor: default; opacity: 0.4; }
button:disabled:hover { filter: none; }

/* Small / Normal / Large buttons for the sheet text size. */
.seg { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.seg button { padding: 0.3rem 0.75rem; font-size: 0.85rem; }
.seg button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

/* The tick boxes next to the sheet (sitter's note lines, Day 2 grid,
   leftover-food line): the label wraps next to the box. */
.check-row { align-items: flex-start; margin-top: 0.35rem; }
.cbx { width: auto; flex: 0 0 auto; margin: 0.2rem 0 0; accent-color: var(--accent); }
.cb-label { font-weight: 500; font-size: 0.85rem; color: var(--fg); cursor: pointer; }

.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 0.7rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.3rem 0.2rem 0.7rem;
  font-size: 0.9rem;
}

.chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.15rem 0.5rem;
  font-size: 0.8rem;
}

.chip button.move { padding: 0.15rem 0.45rem; font-size: 0.95rem; line-height: 1; }

.status { margin: 0.5rem 0 0; font-size: 0.85rem; color: var(--muted); min-height: 1.2em; }
.status.bad { color: #b3261e; }
@media (prefers-color-scheme: dark) { .status.bad { color: #ff9a90; } }

.empty {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 1rem;
  color: var(--muted);
  margin: 0 0 1rem;
}

.sheet {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}

/* Sheet text size. The whole sheet scales from this one font size, and the
   sizes below are in em, so it applies on screen and on paper alike. */
.print-size-small .sheet { font-size: 0.8em; }
.print-size-normal .sheet { font-size: 1em; }
.print-size-large .sheet { font-size: 1.15em; }

.sheet h3 { font-size: 1em; }
.sheet-top h3 { font-size: 1.15em; }
.sheet-sec { margin-top: 0.9rem; border-top: 1px solid var(--line); padding-top: 0.7rem; }
.sheet-cat { margin-top: 0.9rem; border-top: 1px solid var(--line); padding-top: 0.7rem; }
.sheet-cat:first-of-type { border-top: 0; }

.row2 { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 0.4rem; padding: 0.12rem 0; }
.row2 .k { color: var(--muted); font-size: 0.85em; }
.row2 .v { white-space: pre-wrap; overflow-wrap: anywhere; }

.sheet-cat .worry {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  gap: 0.4rem;
  margin: 0.45rem 0 0.1rem;
  padding: 0.45rem 0.6rem;
  background: var(--soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
}

.sheet-cat .worry .k { color: var(--muted); font-size: 0.85em; font-weight: 600; }
.sheet-cat .worry .v { white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 600; }

/* The "fill this in before you print" warning: a cat on medication and no
   out-of-hours vet number written down. Loud on purpose. */
.sheet-sec.notice {
  background: var(--soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 0.6rem 0.7rem;
}
.notice h3 { margin: 0 0 0.25rem; }
.notice .notice-text {
  margin: 0;
  font-size: 0.9em;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* The arrival steps come first on the sheet, so they get their own panel:
   the same shaded, left-edged shape as "Call me if" and the warning above,
   with the step numbers in the accent colour. */
.sheet-sec.arrival-sec {
  background: var(--soft);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 0.6rem 0.7rem;
}
.arrival-sec h3 { margin-bottom: 0.2rem; }
.arrival-sec .step-list { margin-top: 0.2rem; }
.arrival-sec .step-list li { font-weight: 500; }
.arrival-sec .step-list li::marker { color: var(--accent); font-weight: 700; }

.feed-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85em;
  table-layout: fixed;
}

.feed-table th, .feed-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.35rem 0.5rem 0.35rem 0;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.feed-table th {
  font-size: 0.88em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}

.feed-table th:first-child, .feed-table td:first-child { width: 26%; }
.feed-table th:last-child, .feed-table td:last-child { width: 34%; }
.feed-table td.cat-cell { font-weight: 600; padding-right: 0.5rem; }
.feed-table tbody tr:last-child td { border-bottom: 0; }

/* The "Day 2 onward" grid: the same daily lines down the side and three to
   five date columns across, so one printed page covers a longer trip. */
.day-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.85em;
  margin-top: 0.5rem;
}

.day-table th, .day-table td {
  border: 1px solid var(--line);
  padding: 0.3rem 0.45rem;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.day-table th {
  text-align: left;
  font-size: 0.85em;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.day-table th:first-child, .day-table td.day-label { width: 52%; }
.day-table th.day-col { width: 16%; }

/* Each grid column is headed with its day number (Day 2, Day 3 ...), with
   "Date:" under it in the muted colour and a space to write the date in pen. */
.day-col .day-num {
  display: block;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg);
  font-weight: 700;
}
.day-col .day-date { display: block; font-weight: 500; padding-top: 0.55em; }

.day-table td.day-label { text-align: left; }
.day-table td.day-box { text-align: center; }
.day-table .tick {
  display: inline-block;
  width: 1.05rem;
  height: 1.05rem;
  vertical-align: middle;
  border: 1.5px solid var(--muted);
  border-radius: 3px;
}

.step-list { margin: 0.45rem 0 0; padding-left: 1.35rem; font-size: 0.9em; }
.step-list li { padding: 0.2rem 0; overflow-wrap: anywhere; }

/* "Where things are": a flat list of cupboards, so it reads at a glance. */
.where-list { margin: 0.45rem 0 0; padding-left: 1.15rem; font-size: 0.9em; }
.where-list li { padding: 0.16rem 0; overflow-wrap: anywhere; }

.missing-sec .row2 {
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px dotted var(--line);
}

.check-list { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.check-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.28rem 0;
  border-bottom: 1px dotted var(--line);
  font-size: 0.9em;
}
.check-list li:last-child { border-bottom: 0; }
.check-list .tick {
  flex: 0 0 auto;
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.18rem;
  border: 1.5px solid var(--muted);
  border-radius: 3px;
}
.check-list .tick-text { overflow-wrap: anywhere; }

/* The sitter's own notes at the end of the sheet: plain ruled lines, so the
   sheet can be written on and handed back at the end of the trip. */
.log-lines { margin-top: 0.55rem; }
.log-line { border-bottom: 1px solid var(--line); height: 1.9em; }
.log-line:first-child { border-top: 0; }

.sheet-foot { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 0.5rem; font-size: 0.78em; color: var(--muted); }

.plain { margin-top: 1rem; }
.plain summary { cursor: pointer; font-size: 0.9rem; color: var(--muted); }
.plain textarea { margin-top: 0.5rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; }

.about { margin-top: 1.5rem; border-top: 1px solid var(--line); padding-top: 1rem; max-width: 46rem; }
.about p { margin: 0 0 0.5rem; }

footer { margin-top: 1.5rem; color: var(--muted); font-size: 0.85rem; }

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

.hidden { display: none !important; }

/* Text for screen readers only. Each tick line on the sheet carries one, so the
   box is spoken as a tick box instead of being a silent mark. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  @page { margin: 12mm; }
  body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  .no-print, .plain { display: none !important; }
  .sr-only { display: none !important; }
  .sheet-col { position: static; }
  .sheet { border: 0; padding: 0; }
  /* On paper the size is set in points, so the three choices print a
     predictable size whatever the browser's own scale setting is. */
  .print-size-small .sheet { font-size: 10.5pt; }
  .print-size-normal .sheet { font-size: 12.5pt; }
  .print-size-large .sheet { font-size: 14pt; }
  .row2 .k { color: #444; }
  .sheet-cat .worry { background: #f4f4f4; border-left-color: #555; }
  .sheet-sec.notice { background: #f4f4f4; border-left-color: #555; }
  /* The arrival panel prints as light grey with a grey edge, so it still
     stands out on a black-and-white printer. */
  .sheet-sec.arrival-sec { background: #f4f4f4; border-color: #bbb; border-left-color: #555; }
  .arrival-sec .step-list li::marker { color: #333; }
  .feed-table th { color: #444; }
  .feed-table th, .feed-table td { border-bottom-color: #bbb; }
  /* The Day 2 grid prints with grey rules and grey tick boxes, so a pen tick
     inside a box is obvious. The day number stays black so it reads as a heading. */
  .day-table th { color: #444; }
  .day-table th, .day-table td { border-color: #999; }
  .day-col .day-num { color: #000; }
  .day-table .tick { border-color: #444; }
  .check-list .tick { border-color: #444; }
  /* The ruled note lines have to show on paper as well as on screen. */
  .log-line { border-bottom-color: #999; }

  /* Keep a block whole rather than splitting it across a page break. */
  .sheet-top { break-after: avoid; page-break-after: avoid; }
  .sheet-cat { break-inside: avoid; page-break-inside: avoid; }
  .sheet-sec.notice { break-inside: avoid; page-break-inside: avoid; }
  .sheet-sec.arrival-sec { break-inside: avoid; page-break-inside: avoid; }
  .feed-table { break-inside: avoid; page-break-inside: avoid; }
  .day-table { break-inside: avoid; page-break-inside: avoid; }
  .missing-sec { break-inside: avoid; page-break-inside: avoid; }
  .where-list { break-inside: avoid; page-break-inside: avoid; }
  .log-sec { break-inside: avoid; page-break-inside: avoid; }
  .sheet-sec h3, .sheet-cat h3, .feed-table th, .day-table th { break-after: avoid; page-break-after: avoid; }
  .feed-table tr, .day-table tr { break-inside: avoid; page-break-inside: avoid; }
  .check-list li, .step-list li, .where-list li { break-inside: avoid; page-break-inside: avoid; }
}
