:root {
  --brand: #1f4e3c; --brand-ink: #fff; --brand-soft: #e3ede7;
  --bg: #f6f5f1; --card: #fff; --line: #e5e2da; --ink: #1d1d1b; --muted: #6b6a65;
  --late: #b3261e; --soon: #8a5a00; --ok: #1f6b45;
  --thomas: #1d5f8c; --thomas-bg: #e2eef7; --charlene: #8a3f73; --charlene-bg: #f5e6f0;
  --wait: #7e5f00; --wait-bg: #fff1cc; --prog: #06376a; --prog-bg: #cfe1f3;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
  --tabs-h: 58px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #6fbf98; --brand-ink: #0f1d17; --brand-soft: #1e3329;
    --bg: #121412; --card: #1c1f1c; --line: #2c302c; --ink: #ecebe6; --muted: #9b9a94;
    --late: #ff8a80; --soon: #f0b44c; --ok: #7fd1a4;
    --thomas: #8cc3ec; --thomas-bg: #1b2d3b; --charlene: #e7a6d3; --charlene-bg: #3a2333;
    --wait: #f0c654; --wait-bg: #3a3118; --prog: #a9cdf1; --prog-bg: #1c2d40;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.loading { padding: 48px 16px; text-align: center; color: var(--muted); }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 5; background: var(--brand); color: var(--brand-ink);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; max-width: 760px; margin: 0 auto 8px; }
.top h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.sync {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: inherit; opacity: .85;
  font-size: 12px; padding: 6px 2px;
}
.sync .ic { width: 16px; height: 16px; }
.sync.busy .ic { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.seg { display: flex; background: rgba(255,255,255,.14); border-radius: 10px; padding: 3px; max-width: 760px; margin: 0 auto; }
.seg button { flex: 1; border: 0; background: transparent; color: inherit; padding: 7px 4px; border-radius: 8px; font-size: 14px; font-weight: 600; opacity: .85; }
.seg button.on { background: var(--card); color: var(--ink); opacity: 1; box-shadow: 0 1px 2px rgba(0,0,0,.15); }

.banner { max-width: 760px; margin: 8px auto 0; padding: 9px 12px; border-radius: 10px; font-size: 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.banner.sample { background: var(--wait-bg); color: var(--wait); }
.banner.install { background: var(--brand-soft); color: var(--ink); }
.banner button { border: 0; background: transparent; font-size: 16px; padding: 2px 6px; color: var(--muted); }
#banner { padding: 0 12px; }

/* ---------- add box ---------- */
.add { max-width: 760px; margin: 0 auto; padding: 10px 12px 0; }
.addform { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px; box-shadow: var(--shadow); }
.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 8px 6px; font-size: 16px; outline: none; }
.add-btn { border: 0; border-radius: 9px; background: var(--brand); color: var(--brand-ink); font-weight: 700; padding: 8px 16px; }
.add-extra { display: none; padding: 6px 2px 2px; border-top: 1px solid var(--line); margin-top: 6px; }
.addform.open .add-extra { display: block; }
.add-hint { margin: 4px 6px 2px; font-size: 12px; color: var(--muted); }
.addform.open .add-hint { display: none; }
.store-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 2px 8px; }
.fields { display: flex; flex-wrap: wrap; gap: 8px; }
.fld { display: flex; flex-direction: column; gap: 3px; flex: 1 1 140px; min-width: 0; font-size: 12px; color: var(--muted); }
.fld.wide { flex-basis: 100%; }
.fld input, .fld select {
  width: 100%; min-width: 0; font-size: 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px; min-height: 40px; -webkit-appearance: none; appearance: none;
}
.fld select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }

/* ---------- lists ---------- */
.list { max-width: 760px; margin: 0 auto; padding: 4px 12px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 28px); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
.chips::-webkit-scrollbar { display: none; }
.chips + .chips { padding-top: 6px; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px;
  padding: 7px 13px; font-size: 14px; white-space: nowrap;
}
.chip.sm { padding: 5px 11px; font-size: 13px; }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }

.group { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; margin: 20px 4px 7px; display: flex; gap: 8px; align-items: center; }
.count { font-size: 12px; font-weight: 600; background: var(--line); color: var(--muted); border-radius: 999px; padding: 1px 7px; letter-spacing: 0; text-transform: none; }
.hint { margin: -2px 4px 8px; font-size: 13px; color: var(--muted); }

.card { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.card + .card { margin-top: 10px; }
.card.empty { padding: 16px; color: var(--muted); font-size: 15px; }
.item { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border-top: 1px solid var(--line); transition: opacity .25s; }
.item:first-child { border-top: 0; }
.item-body { flex: 1; min-width: 0; }
.item-title { font-size: 16px; overflow-wrap: anywhere; }
.item-meta { font-size: 13px; color: var(--muted); margin-top: 3px; display: flex; flex-wrap: wrap; align-items: center; row-gap: 3px; }
.item-meta .dot { padding: 0 5px; white-space: pre; }
.item.is-sub { padding-left: 44px; background: color-mix(in srgb, var(--bg) 55%, var(--card)); }
.item.is-sub .check { width: 24px; height: 24px; }
.item.is-pending .item-title, .item.is-done .item-title { text-decoration: line-through; color: var(--muted); }
.item.is-pending { opacity: .6; }
.check {
  flex: none; width: 28px; height: 28px; margin-top: -1px; border-radius: 8px; border: 2px solid var(--brand); background: transparent;
  display: grid; place-items: center; padding: 0; color: transparent;
}
.check .ic-check { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.check.on { background: var(--brand); color: var(--brand-ink); }
.check:disabled { cursor: default; }
.check:disabled:not(.on) { opacity: .4; }
.bullet { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin: 8px 6px 0 4px; }
.late { color: var(--late); font-weight: 600; }
.soon { color: var(--soon); font-weight: 600; }
.ok { color: var(--ok); }
.who { font-size: 12px; font-weight: 600; border-radius: 6px; padding: 1px 6px; }
.who-thomas { color: var(--thomas); background: var(--thomas-bg); }
.who-charlene { color: var(--charlene); background: var(--charlene-bg); }
.who-other { color: var(--muted); background: var(--line); }
.pill { font-size: 12px; font-weight: 600; border-radius: 6px; padding: 1px 6px; }
.pill-waiting { color: var(--wait); background: var(--wait-bg); }
.pill-in-progress { color: var(--prog); background: var(--prog-bg); }
.pill-someday, .pill-done { color: var(--muted); background: var(--line); }
.oncal { color: var(--muted); padding-top: 2px; }
.ic, .oncal svg, .buys svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.project .next { font-size: 14px; margin-top: 6px; }
.progress { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.bar { flex: 1; max-width: 180px; height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.buys { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px 12px 44px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink); }
.buys svg { flex: none; color: var(--muted); width: 16px; height: 16px; margin-top: 1px; }

.hello { margin: 14px 4px 0; }
.hello-date { font-size: 13px; color: var(--muted); font-weight: 600; }
.hello-sum { font-size: 20px; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; }

details.more { margin-top: 18px; }
details.more summary { list-style: none; cursor: pointer; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; margin: 0 4px 7px; display: flex; gap: 8px; align-items: center; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "▸"; font-size: 11px; }
details.more[open] summary::before { content: "▾"; }

/* ---------- bottom tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 4px calc(env(safe-area-inset-bottom) + 4px); min-height: var(--tabs-h);
}
.tabs button { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; padding: 2px 0; }
.tabs button.on { color: var(--brand); font-weight: 700; }
.tab-ic { position: relative; }
.tab-ic .ic { width: 24px; height: 24px; }
.badge { position: absolute; top: -4px; right: -10px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: var(--late); color: #fff; font-size: 11px; line-height: 17px; text-align: center; font-weight: 700; }
.badge.warn { background: var(--soon); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px); z-index: 7;
  max-width: 520px; margin: 0 auto; background: #262624; color: #fff; border-radius: 12px; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 15px; box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
.toast.err { background: #8c1d18; }
.toast button { border: 0; background: transparent; color: #9fe3bd; font-weight: 700; font-size: 15px; padding: 4px 6px; }

/* ---------- sign in ---------- */
.signin { max-width: 380px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 72px) 24px 40px; text-align: center; }
.signin img { border-radius: 20px; }
.signin h1 { margin: 16px 0 6px; font-size: 28px; }
.signin p { color: var(--muted); }
.google { margin: 20px 0 10px; width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 14px; font-weight: 700; font-size: 16px; }
