:root {
  --bg: #f6efe2;
  --card: #fffaf1;
  --ink: #2b2118;
  --muted: #7a6a58;
  --line: #e6d9c3;
  --sun: #e9a23b;
  --sun-deep: #c97f17;
  --leaf: #5b8a5a;
  --warn: #b5523b;
  --chip: #f1e5cf;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 10, .06), 0 4px 14px rgba(60, 40, 10, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1915; --card: #27221c; --ink: #f2e9da; --muted: #b3a38d; --line: #3b342b;
    --chip: #342d24; --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.45 Inter, system-ui, -apple-system, sans-serif; -webkit-text-size-adjust: 100%; }
#app { max-width: 880px; margin: 0 auto; padding: 0 16px 64px; }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 700; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--warn); min-height: 1.2em; margin: 6px 0 0; font-size: 14px; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 18px 0 10px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 28px; }
.sun { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffd27a, var(--sun) 60%, var(--sun-deep)); box-shadow: 0 0 0 4px rgba(233,162,59,.18); }
.top-right { display: flex; align-items: center; gap: 8px; }
.status { font-size: 12px; color: var(--muted); }
.status.bad { color: var(--warn); }

.tabs { display: flex; gap: 4px; background: var(--chip); padding: 4px; border-radius: 999px; margin: 4px 0 18px; overflow-x: auto; }
.tabs button { flex: 1; border: 0; background: transparent; color: var(--muted); font: 600 14px Inter, sans-serif; padding: 9px 10px; border-radius: 999px; white-space: nowrap; cursor: pointer; }
.tabs button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

.btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 600 14px Inter, sans-serif; padding: 9px 14px; border-radius: 10px; cursor: pointer; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--sun); border-color: var(--sun-deep); color: #2b1a05; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { color: var(--warn); }
.icon { border: 0; background: transparent; color: var(--muted); font-size: 18px; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; flex: none; }
.icon:hover { background: var(--chip); }
.icon.on { color: var(--sun-deep); }

input, select, textarea { font: 15px Inter, sans-serif; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--sun); outline-offset: 0; }
.field { display: block; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
label.field > input, label.field > select { display: block; width: 100%; margin-top: 4px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--chip); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; color: var(--muted); }
.chip.id { font-family: ui-monospace, Menlo, monospace; letter-spacing: .02em; }
.chip.warn { background: rgba(181,82,59,.14); color: var(--warn); }
.chip.leaf { background: rgba(91,138,90,.15); color: var(--leaf); }

/* week nav */
.weeknav { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.weeknav .date { flex: 1; text-align: center; }
.weeknav .date h2 { font-size: 21px; }
.weeknav input[type=date] { font-size: 13px; padding: 4px 8px; margin-top: 4px; }

/* lists view */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.person h3 { display: flex; justify-content: space-between; align-items: baseline; }
.person ul { list-style: none; margin: 10px 0 0; padding: 0; }
.person li { padding: 7px 0; border-top: 1px dashed var(--line); display: flex; gap: 10px; align-items: flex-start; }
.person li:first-child { border-top: 0; }
.box { width: 16px; height: 16px; border: 2px solid var(--muted); border-radius: 4px; flex: none; margin-top: 2px; }
.person.together { background: linear-gradient(180deg, rgba(233,162,59,.10), transparent 60%), var(--card); }
.empty { color: var(--muted); font-style: italic; }

/* assign rows */
.arow { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.arow:first-child { border-top: 0; padding-top: 2px; }
.arow .what { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.arow .what .name { font-weight: 600; }
.arow .what input.x { width: 110px; padding: 4px 8px; font-size: 14px; }
.arow .who { display: flex; align-items: center; gap: 2px; }
.arow .who select { width: 120px; }
.arow .hint { grid-column: 1 / -1; font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.load { display: flex; gap: 8px; flex-wrap: wrap; }
.load .chip b { color: var(--ink); }

/* bank */
.chore { border-top: 1px solid var(--line); padding: 12px 0; }
.chore:first-of-type { border-top: 0; }
.chore summary { list-style: none; cursor: pointer; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chore summary::-webkit-details-marker { display: none; }
.chore summary .name { font-weight: 600; flex: 1; min-width: 140px; }
.chore .edit { margin-top: 12px; padding: 12px; background: var(--bg); border-radius: 10px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--ink); font-size: 14px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; }
.archived { opacity: .55; }

/* history */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.hist { border-collapse: collapse; width: 100%; font-size: 13px; }
table.hist th, table.hist td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.hist th { font-weight: 600; color: var(--muted); font-size: 12px; }
table.hist td.c { color: var(--ink); }
table.hist td .n { font-weight: 600; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); padding: 20px; width: min(380px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(30, 20, 10, .35); }
dialog h2 { margin-bottom: 6px; }
dialog input { width: 100%; margin-top: 10px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 10; }

/* ---------- print ---------- */
#print { display: none; }
@media print {
  @page { margin: 0.45in; }
  html, body { background: #fff !important; color: #000 !important; }
  #app, dialog, .toast { display: none !important; }
  #print { display: block; font-family: Inter, system-ui, sans-serif; color: #000; }
  .p-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 14px; }
  .p-head h1 { font-family: Fraunces, Georgia, serif; font-size: 26pt; }
  .p-head .d { font-size: 13pt; }
  .p-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .p-card { border: 1.5px solid #000; border-radius: 10px; padding: 12px 14px; break-inside: avoid; page-break-inside: avoid; }
  .p-card h2 { font-family: Fraunces, Georgia, serif; font-size: 20pt; margin-bottom: 6px; }
  .p-card .sub { font-size: 9.5pt; color: #444; margin-bottom: 4px; }
  .p-card ul { list-style: none; margin: 0; padding: 0; }
  .p-card li { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px dotted #999; font-size: 13pt; }
  .p-card li.blank { height: 30px; }
  .p-card .pbox { width: 15px; height: 15px; border: 2px solid #000; border-radius: 3px; flex: none; margin-top: 3px; }
  .p-card .who { margin-left: auto; font-size: 10pt; color: #444; }
  .p-card.wide { grid-column: 1 / -1; }
  .p-pages .p-card { border: 0; padding: 0; break-after: page; page-break-after: always; }
  .p-pages .p-card:last-child { break-after: auto; page-break-after: auto; }
  .p-pages .p-card h2 { font-size: 34pt; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 4px; }
  .p-pages .p-card .sub { font-size: 13pt; margin-bottom: 14px; }
  .p-pages .p-card li { font-size: 18pt; padding: 14px 0; }
  .p-pages .p-card .pbox { width: 22px; height: 22px; margin-top: 4px; }
  .p-pages .p-card li.blank { height: 54px; }
}
