/* Reilly Home. System fonts only, no external resources. */
:root {
  --bg: #f5f3ef; --card: #ffffff; --ink: #1d1f23; --ink-2: #5d636d; --ink-3: #9aa0a8;
  --line: rgba(20, 22, 26, .08); --accent: #2f6fdf; --shadow: 0 1px 2px rgba(20,22,26,.05), 0 6px 20px rgba(20,22,26,.06);
  --overdue: #d6453d; --groceries: #2e9d62; --todos: #c9861a; --new: #2f6fdf;
  --overdue-bg: rgba(214,69,61,.10); --groceries-bg: rgba(46,157,98,.10); --todos-bg: rgba(201,134,26,.12); --new-bg: rgba(47,111,223,.10);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a; --card: #1e2127; --ink: #eceef1; --ink-2: #a4aab3; --ink-3: #6c727b;
    --line: rgba(255,255,255,.08); --accent: #6aa0ff; --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.35);
    --overdue: #ff7a70; --groceries: #4fd08a; --todos: #f0b14a; --new: #79a8ff;
    --overdue-bg: rgba(255,122,112,.14); --groceries-bg: rgba(79,208,138,.13); --todos-bg: rgba(240,177,74,.14); --new-bg: rgba(121,168,255,.14);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161a; --card: #1e2127; --ink: #eceef1; --ink-2: #a4aab3; --ink-3: #6c727b;
  --line: rgba(255,255,255,.08); --accent: #6aa0ff; --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.35);
  --overdue: #ff7a70; --groceries: #4fd08a; --todos: #f0b14a; --new: #79a8ff;
  --overdue-bg: rgba(255,122,112,.14); --groceries-bg: rgba(79,208,138,.13); --todos-bg: rgba(240,177,74,.14); --new-bg: rgba(121,168,255,.14);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: contain;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.top { padding: 18px 18px 6px; max-width: 760px; margin: 0 auto; }
.top-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.eyebrow { margin: 0 0 2px; color: var(--ink-2); font-size: 13px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
h1 { margin: 0; font-size: 32px; line-height: 1.1; letter-spacing: -.02em; font-weight: 800; }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow);
  display: grid; place-items: center; transition: transform .15s ease, opacity .15s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.cooldown { opacity: .5; }
body.loading #refresh svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sync-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); background: var(--card);
  border-radius: 999px; padding: 5px 10px; box-shadow: var(--shadow); }
.pill b { color: var(--ink); font-weight: 600; }
.pill.muted { background: transparent; box-shadow: none; padding-left: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.dot.ok { background: var(--groceries); }
.dot.bad { background: var(--overdue); }
.dot.syncing { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.mock-banner { margin-top: 10px; font-size: 12.5px; color: var(--todos); background: var(--todos-bg); padding: 7px 11px; border-radius: 10px; font-weight: 600; }

main { padding: 8px 14px 40px; max-width: 760px; margin: 0 auto; }
.error { background: var(--overdue-bg); color: var(--ink); border-left: 4px solid var(--overdue); padding: 12px 14px; border-radius: 12px; margin: 6px 4px 12px; font-size: 14.5px; }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0 14px; }
.stat { text-decoration: none; color: var(--ink); background: var(--card); border-radius: 16px; padding: 11px 8px 10px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 2px; border-top: 3px solid transparent; }
.stat-n { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 11.5px; color: var(--ink-2); font-weight: 600; text-align: center; }
.stat-overdue { border-top-color: var(--overdue); } .stat-overdue .stat-n { color: var(--overdue); }
.stat-groceries { border-top-color: var(--groceries); }
.stat-todos { border-top-color: var(--todos); }
.stat-justAdded { border-top-color: var(--new); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; scroll-margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; gap: 10px; }
.card h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.card h2::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c, var(--accent)); }
.card-sub { margin: 2px 0 0 18px; font-size: 12.5px; color: var(--ink-3); }
.count { min-width: 30px; height: 26px; padding: 0 9px; border-radius: 999px; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; background: var(--cbg, var(--new-bg)); color: var(--c, var(--accent)); }
.card-overdue { --c: var(--overdue); --cbg: var(--overdue-bg); }
.card-groceries { --c: var(--groceries); --cbg: var(--groceries-bg); }
.card-todos { --c: var(--todos); --cbg: var(--todos-bg); }
.card-justAdded { --c: var(--new); --cbg: var(--new-bg); }
.card-overdue { box-shadow: var(--shadow), inset 4px 0 0 var(--overdue); }

.list { list-style: none; margin: 0; padding: 0 0 6px; }
.item { display: flex; gap: 12px; align-items: flex-start; padding: 11px 16px; border-top: 1px solid var(--line); transition: opacity .2s; }
.check { flex: none; width: 26px; height: 26px; margin-top: 1px; border-radius: 50%; border: 2px solid var(--c, var(--ink-3));
  background: transparent; display: grid; place-items: center; padding: 0; transition: background .15s, transform .12s; }
.check:active { transform: scale(.88); }
.check svg { width: 15px; height: 15px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.item.checked .check { background: var(--c, var(--accent)); }
.item.checked .check svg { opacity: 1; }
.item.checked { opacity: .5; }
.item.checked .item-text { text-decoration: line-through; }
.item-body { min-width: 0; flex: 1; }
.item-text { margin: 0; font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.card-justAdded .item-text { font-weight: 450; color: var(--ink); }
.item-meta { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-3); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.sep { opacity: .6; }
.flag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; display: inline-block; }
.flag.flag-check { background: var(--todos-bg); color: var(--todos); }
.flag.flag-dup { background: var(--overdue-bg); color: var(--overdue); }
.due { font-weight: 600; color: var(--ink-2); }
.card-overdue .due { color: var(--overdue); }

.empty { padding: 4px 16px 18px; color: var(--ink-3); font-size: 14.5px; }
.empty p { margin: 0; padding: 14px; border: 1.5px dashed var(--line); border-radius: 12px; text-align: center; }

.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-size: 14px; max-width: calc(100% - 32px);
  box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 20; text-align: center; }

.ptr { position: fixed; top: env(safe-area-inset-top); left: 0; right: 0; display: flex; justify-content: center; align-items: center; gap: 8px;
  height: 44px; transform: translateY(-60px); color: var(--ink-2); font-size: 13px; z-index: 5; pointer-events: none; transition: transform .2s; }
.ptr-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.ptr.ready .ptr-dot { background: var(--accent); }

.sheet { border: 0; padding: 0; width: min(520px, 100%); max-width: 100%; background: var(--card); color: var(--ink);
  border-radius: 22px 22px 0 0; margin: auto auto 0; box-shadow: 0 -10px 40px rgba(0,0,0,.25); }
@media (min-width: 600px) { .sheet { border-radius: 22px; margin: auto; } }
.sheet::backdrop { background: rgba(10,12,16,.45); }
.sheet form { padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.sheet h2 { margin: 0; font-size: 22px; }
.sheet label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.sheet input, .sheet select { padding: 12px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 16px; color: var(--ink); }
.help { margin: 0; font-size: 14px; color: var(--ink-2); }
.help.small { font-size: 12.5px; color: var(--ink-3); }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.btn { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 650; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink-2); }
.btn.danger { color: var(--overdue); margin-right: auto; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.footnote { text-align: center; font-size: 13px; color: var(--muted, #888); margin: 18px 24px 8px; line-height: 1.4; }
.item-meta { flex-wrap: wrap; row-gap: 4px; }
