:root {
  --bg: #faf6f0; --card: #fff; --ink: #2a2420; --muted: #6f6359; --line: #e4dacd;
  --accent: #a2441c; --on-accent: #fff; --tint: #f6e9e0;
  --ok: #256b49; --ok-bg: #e1f0e7; --warn: #7a4e00; --warn-bg: #fbecd0; --danger: #b3261e;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1815; --card: #26221e; --ink: #efe8df; --muted: #a99d91; --line: #3d362f;
    --accent: #e9976a; --on-accent: #1b1815; --tint: #33271f;
    --ok: #86d3aa; --ok-bg: #1f3a2c; --warn: #f0c36d; --warn-bg: #40321a; --danger: #f2877f;
  }
}

* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
h1, h2, .brand { font-family: ui-serif, "Iowan Old Style", Georgia, serif; line-height: 1.2; margin: 0; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.2rem; }
a { color: var(--accent); }
small { display: block; color: var(--muted); font-size: .85rem; }
.muted { color: var(--muted); }
.lead { font-size: 1.1rem; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; padding: .75rem 1rem; border-bottom: 1px solid var(--line); background: var(--card); }
.brand { font-size: 1.3rem; font-weight: 700; color: var(--ink); text-decoration: none; }
.top nav { display: flex; gap: 1rem; }
.top nav a { text-decoration: none; padding: .25rem 0; }
main { max-width: 64rem; margin: 0 auto; padding: 1rem 1rem 4rem; }
main > * + * { margin-top: 1rem; }

.flash { background: var(--ok-bg); color: var(--ok); border-radius: .5rem; padding: .6rem .9rem; font-weight: 600; }
.empty { color: var(--muted); border: 1px dashed var(--line); border-radius: .75rem; padding: 1.25rem; text-align: center; }
.bar { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; }
.bar > * { margin: 0; }
main > .bar:not(:first-child) { margin-top: 2rem; }

/* buttons and inputs */
button, .btn { white-space: nowrap; font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); border-radius: .5rem; padding: .5rem .9rem; text-decoration: none; display: inline-block; min-height: 2.5rem; }
button.quiet { background: transparent; color: var(--accent); border-color: var(--line); padding: .35rem .7rem; min-height: 2.25rem; }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.quiet.danger { border-color: var(--line); }
label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: .75rem; }
input, textarea, select { display: block; width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: .5rem; padding: .5rem .6rem; margin-top: .2rem; min-height: 2.5rem; }
input[type=checkbox] { display: inline-block; width: 1.15rem; height: 1.15rem; min-height: 0; margin: 0; vertical-align: -.15rem; accent-color: var(--accent); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0 1rem; }
.checks { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; margin-bottom: .75rem; }
.check { font-weight: 400; font-size: 1rem; margin: 0; padding: .35rem 0; }
fieldset { border: 1px solid var(--line); border-radius: .5rem; margin: 0 0 .75rem; padding: .5rem .9rem 0; }
legend { font-size: .9rem; font-weight: 600; padding: 0 .3rem; }

/* surfaces */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: .75rem; padding: 1rem; }
.panel > h2 { margin-bottom: .5rem; }
.narrow { max-width: 24rem; margin: 3rem auto; }
.narrow-form { max-width: 28rem; }
details.panel > summary { cursor: pointer; font-weight: 600; color: var(--accent); }
details.panel[open] > summary { margin-bottom: .75rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1rem; }
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: .75rem; padding: 1rem; color: inherit; text-decoration: none; }
.card:hover { border-color: var(--accent); }
.card h2 { color: var(--accent); }
.card p { margin: .35rem 0 0; }
.past { opacity: .6; }

.tabs, .pills { display: flex; gap: .25rem; overflow-x: auto; }
.tabs { border-bottom: 1px solid var(--line); }
.tabs a { padding: .6rem .8rem; text-decoration: none; color: var(--muted); white-space: nowrap; border-bottom: 3px solid transparent; font-weight: 600; }
.tabs a[aria-current] { color: var(--accent); border-color: var(--accent); }
.pills a { padding: .3rem .8rem; border: 1px solid var(--line); border-radius: 2rem; text-decoration: none; white-space: nowrap; font-size: .9rem; }
.pills a[aria-current] { background: var(--tint); border-color: var(--accent); font-weight: 600; }

.stats, .facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .75rem; margin: 1rem 0; }
.stats div, .facts div { background: var(--card); border: 1px solid var(--line); border-radius: .75rem; padding: .7rem .9rem; }
.facts { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
dt { font-size: .8rem; color: var(--muted); font-weight: 600; }
dd { margin: 0; font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.facts dd { font-size: 1rem; font-weight: 400; }

.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: .1rem .5rem; border-radius: 1rem; background: var(--tint); color: var(--accent); white-space: nowrap; vertical-align: .1em; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

/* tables */
.scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: .75rem; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: .55rem .6rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
thead th { font-size: .8rem; color: var(--muted); white-space: nowrap; }
tbody tr:last-child > *, tfoot tr:last-child > * { border-bottom: 0; }
tbody + tbody, tfoot { border-top: 2px solid var(--line); }
.r { text-align: right; }
.group th { background: var(--tint); font-family: ui-serif, Georgia, serif; }
tr.off td:not(:first-child), tr.done td:not(:first-child), li.done > span:first-child, .line.done input { opacity: .55; }
tr.done td:nth-child(2) a, .line.done input[name=title] { text-decoration: line-through; }
tr.picked { background: var(--tint); }
tfoot th { text-align: right; font-weight: 400; }
.grand > * { font-weight: 700; font-size: 1.05rem; }
td small.note { font-style: italic; }
@media (max-width: 44rem) { .wide { display: none; } }

/* one-click checkbox */
.tog { display: inline; margin: 0; }
.box { width: 1.75rem; height: 1.75rem; min-height: 0; padding: 0; line-height: 1; border: 2px solid var(--muted); background: var(--card); color: var(--on-accent); border-radius: .4rem; }
.box.on { background: var(--ok); border-color: var(--ok); color: var(--card); }

/* lists and editable rows */
.store > * + * { margin-top: .6rem; }
.plain { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: .75rem; }
.plain li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
.plain li:last-child { border-bottom: 0; }
.plain li > span:first-child { flex: 1 1 14rem; }
.line { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; background: var(--card); border: 1px solid var(--line); border-radius: .75rem; padding: .5rem; }
.line input { flex: 1 1 9rem; width: auto; margin: 0; }
.line input[name=title], .line.new input:first-of-type { flex: 3 1 14rem; }
.line .first { order: -1; }
.line .when { flex: 0 0 6.5rem; }
.line.open { border-color: var(--warn); border-style: dashed; }
.line.new { background: transparent; border-style: dashed; }

.claim { flex: 0 1 auto; }
.claim > summary { cursor: pointer; list-style: none; font-weight: 600; color: var(--on-accent); background: var(--accent); border-radius: .5rem; padding: .5rem .9rem; display: inline-block; }
.claim > summary::-webkit-details-marker { display: none; }
.claim[open] { flex: 1 1 100%; }
.claim[open] > summary { background: transparent; color: var(--muted); padding-left: 0; }
.claim form { max-width: 24rem; }

@media print {
  .top, .tabs, .noprint, .tog, .flash { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  main { max-width: none; padding: 0; }
  .scroll { border: 0; overflow: visible; }
  .store { break-inside: avoid; }
  .checklist td:first-child::before { content: "☐"; }
  .checklist tr.done td:first-child::before { content: "☑"; }
  a { color: inherit; text-decoration: none; }
}
