:root {
  --bg: #f5f4f0;
  --card: #ffffff;
  --text: #1c1b19;
  --dim: #77736b;
  --line: #e4e1da;
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --accent-soft: #e3efe8;
  --late: #b3261e;
  --late-soft: #fbe7e5;
  --warn-soft: #fdf3d8;
  --warn: #7a5a00;
  --field: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --card: #211f1d;
    --text: #f1eee8;
    --dim: #9a958c;
    --line: #36332f;
    --accent: #6cc196;
    --accent-ink: #0f1a14;
    --accent-soft: #1f3329;
    --late: #ff8a80;
    --late-soft: #3a1f1d;
    --warn-soft: #3a3020;
    --warn: #f0cf7a;
    --field: #191817;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 36rem; margin: 0 auto; padding: 16px 16px 64px; }
main.wide { max-width: 52rem; }

header.top { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 8px 0 20px; }
header.top h1 { font-size: 1.35rem; margin: 0; letter-spacing: -.01em; }
header.top .me { font-size: .95rem; }
header.top nav { display: flex; gap: 14px; font-size: .95rem; margin-left: auto; }

a { color: var(--accent); }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

/* Data vs. connecting words */
.w { color: var(--dim); }
.v { font-weight: 600; color: var(--text); white-space: nowrap; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card h2 { margin: 0; font-size: 1.15rem; }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head .spacer { flex: 1; }
.card h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); margin: 18px 0 6px; font-weight: 600; }

.current { font-size: 1.05rem; }
.current .who { font-size: 1.2rem; }
.current p { margin: 2px 0; }

.pill {
  display: inline-block; font-size: .8rem; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.pill.late { background: var(--late-soft); color: var(--late); }
.pill.muted { background: var(--line); color: var(--dim); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { padding: 5px 0; border-top: 1px solid var(--line); display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.rows li:first-child { border-top: 0; }
.delta { font-variant-numeric: tabular-nums; font-weight: 600; }
.delta.late { color: var(--late); }
.delta.early { color: var(--dim); }

button, .btn {
  font: inherit; font-weight: 600; border-radius: 10px; padding: 9px 16px; cursor: pointer;
  border: 1px solid var(--line); background: var(--field); color: var(--text); white-space: nowrap;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.big { width: 100%; padding: 14px; font-size: 1.05rem; margin-top: 14px; }
button.small { padding: 5px 11px; font-size: .9rem; border-radius: 8px; }
button.danger { color: var(--late); }
button:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

input, select {
  font: inherit; color: var(--text); background: var(--field); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; min-width: 0;
}
input[type=number] { width: 5em; text-align: center; }
input[type=checkbox] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

/* Label column right-aligned against left-aligned controls */
.form { display: grid; grid-template-columns: max-content minmax(0, 17rem); gap: 10px 12px; align-items: center; }
.form > .label { text-align: right; color: var(--dim); }
.form > .full { grid-column: 2; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

dialog {
  border: 1px solid var(--line); border-radius: 16px; padding: 20px; background: var(--card); color: var(--text);
  width: min(26rem, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
@media (prefers-color-scheme: dark) { dialog::backdrop { background: rgba(0,0,0,.65); } }
dialog h2 { margin: 0 0 8px; font-size: 1.15rem; }
dialog p { margin: 6px 0; }
dialog .actions { justify-content: flex-end; margin-top: 18px; }

.names { display: grid; gap: 8px; margin-top: 12px; }
.names button { padding: 12px; font-size: 1.05rem; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); max-width: calc(100vw - 32px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .95rem;
  box-shadow: 0 6px 24px rgba(0,0,0,.25); z-index: 10;
}
.toast .v, .toast .w { color: inherit; }
.toast .w { opacity: .7; }
.toast.error { background: var(--late); color: #fff; }

.note { font-size: .9rem; color: var(--dim); }
.banner { border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; background: var(--warn-soft); color: var(--warn); }
.banner .v { color: inherit; }

table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th { text-align: left; font-weight: 600; color: var(--dim); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px; }
td { padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.table-wrap { overflow-x: auto; }
.num { font-variant-numeric: tabular-nums; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; font-weight: 500; padding: 7px 12px; }
.seg button[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.preview { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); }
.preview p { margin: 2px 0; }
.was { text-decoration: line-through; color: var(--dim); }

.inline-settings { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

details summary { cursor: pointer; color: var(--dim); font-size: .9rem; margin-top: 14px; }

/* ---------- per-chore identity ---------- */
.card[data-chore] { --c: var(--accent); --c-soft: var(--accent-soft); --c-ink: var(--accent-ink); }
.card[data-chore=lawn] { --c: #2f7d4a; --c-soft: #e3f2e7; --c-ink: #ffffff; }
.card[data-chore=bathroom] { --c: #2766a8; --c-soft: #e2edf9; --c-ink: #ffffff; }
@media (prefers-color-scheme: dark) {
  .card[data-chore=lawn] { --c: #6fcf8f; --c-soft: #1b3324; --c-ink: #0d1a12; }
  .card[data-chore=bathroom] { --c: #82b8f2; --c-soft: #1a2a3d; --c-ink: #0c1626; }
}
.card[data-chore] button.primary { background: var(--c); border-color: var(--c); color: var(--c-ink); }
.card[data-chore] .pill:not(.late):not(.muted) { background: var(--c-soft); color: var(--c); }

.icon { display: inline-grid; place-items: center; }
.icon svg { width: 100%; height: 100%; }

.card.chore { padding: 0; overflow: hidden; }
.chore-band {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  background: var(--c-soft); border-bottom: 1px solid var(--line);
}
.chore-band h2 { font-size: 1.35rem; letter-spacing: -.01em; }
.chore-band .spacer { flex: 1; }
.chore-band .pill.muted { background: var(--card); }
.chore-icon {
  width: 40px; height: 40px; border-radius: 12px; background: var(--c); color: var(--c-ink);
  display: grid; place-items: center; flex: none;
}
.chore-icon .icon { width: 24px; height: 24px; }
.chore-body { padding: 16px 18px 18px; }

/* Admin cards get a stripe in the chore's colour */
.card[data-chore]:not(.chore) { border-top: 4px solid var(--c); }

/* ---------- timeline: past (solid, checked) → now → future (dashed, hollow) ---------- */
.timeline { list-style: none; margin: 20px 0 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 32px; min-height: 22px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline .dot {
  position: absolute; left: 0; top: 1px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; box-sizing: border-box; z-index: 1; background: var(--card);
}
/* connector to the next item */
.timeline li:not(:last-child)::after {
  content: ""; position: absolute; left: 9px; top: 21px; bottom: -1px; border-left: 2px solid var(--c);
}
.timeline li.now:not(:last-child)::after,
.timeline li.future:not(:last-child)::after { border-left: 2px dashed var(--line); }

.timeline .past .dot { background: var(--c); color: var(--c-ink); }
.timeline .past .dot .icon { width: 13px; height: 13px; }
.timeline .past .v { font-weight: 500; }
.timeline .past { color: var(--dim); }

.timeline .now .dot { border: 2px solid var(--c); background: var(--c-soft); box-shadow: 0 0 0 4px var(--c-soft); }
.timeline .now .dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.timeline .now > div { font-weight: 600; }
.timeline .now .w { color: var(--c); font-weight: 600; }

.timeline .future .dot { border: 2px dashed var(--dim); }
.timeline .future .v { font-weight: 500; color: var(--dim); }

.hidden { display: none !important; }

@media (max-width: 480px) {
  .form { grid-template-columns: 1fr; gap: 4px; }
  .form > .label { text-align: left; margin-top: 6px; }
  .form > .full { grid-column: 1; }
  .hide-narrow { display: none; }
}

/* ---------- relative dates, "every N days", mini calendar ---------- */
.rel { margin: 4px 0 0; font-size: .92rem; font-weight: 600; color: var(--c, var(--accent)); }
.rel.late { color: var(--late); }
.rel-inline { color: var(--dim); font-size: .85rem; white-space: nowrap; }
.rel-inline::before { content: "· "; }
.timeline .future .rel-inline { opacity: .85; }

.chore-title { display: flex; flex-direction: column; line-height: 1.15; }
.every { font-size: .8rem; color: var(--dim); font-weight: 500; margin-top: 3px; }

.cal { margin-top: 14px; max-width: 17rem; }
.cal-month { font-size: .72rem; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 3px; }
.cal-dow { font-size: .68rem; color: var(--dim); text-align: center; padding-bottom: 2px; }
.cal-day { height: 30px; display: grid; place-items: center; font-size: .82rem; font-variant-numeric: tabular-nums; }
.cal-day .n { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%; }
.cal-day .n.m1 { font-weight: 700; }
.cal-day.past { color: var(--dim); }
.cal-day.past .n { opacity: .6; }
/* the window: a continuous band, rounded at its ends and at week edges */
.cal-day.in { background: color-mix(in srgb, var(--c) 22%, transparent); }
.cal-day.in.first, .cal-day.in:nth-child(7n+1) { border-top-left-radius: 15px; border-bottom-left-radius: 15px; }
.cal-day.in.last, .cal-day.in:nth-child(7n) { border-top-right-radius: 15px; border-bottom-right-radius: 15px; }
.cal-day.first .n, .cal-day.last .n { background: var(--c); color: var(--c-ink); font-weight: 700; opacity: 1; }
.cal-day.today .n { box-shadow: 0 0 0 2px var(--text); font-weight: 700; opacity: 1; }
.cal-legend { display: flex; gap: 14px; font-size: .74rem; color: var(--dim); margin-top: 6px; }
.cal-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 5px; vertical-align: -2px; }
.cal-legend .sw.range { background: color-mix(in srgb, var(--c) 45%, transparent); }
.cal-legend .sw.today { border-radius: 50%; box-shadow: inset 0 0 0 2px var(--text); }

/* Email settings */
.stack { display: grid; gap: 10px; }
.notify-form { grid-template-columns: max-content minmax(0, 32rem); align-items: start; }
.notify-form > .label { padding-top: 2px; }
.notify-form .check { align-items: flex-start; }
.notify-form .check input[type=checkbox] { margin-top: 3px; flex: none; }
.notify-form .check input[type=number] { width: 4em; padding: 2px 6px; }

/* Roommate rows wrap on narrow screens instead of clipping */
.rm-list { display: grid; gap: 0; }
.rm-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 0; border-top: 1px solid var(--line); }
.rm-row:first-child { border-top: 0; }
.rm-fields { display: flex; flex-wrap: wrap; gap: 8px; }
.rm-fields input[type=email] { width: 16rem; max-width: 100%; }
.rm-fields input:not([type]) { width: 7rem; }
