:root {
  --bg: #f2f2f7;
  --panel: #ffffff;
  --tint: #f5f5f7;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(60, 60, 67, .14);
  --accent: #0a7cff;
  --care: #d6336c;
  --good: #34c759;
  --warn: #ff9500;
  --late: #ff3b30;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --panel: #1c1c1e; --tint: #2c2c2e; --text: #f5f5f7; --muted: #98989d;
    --line: rgba(84, 84, 88, .5); --accent: #0a84ff; --care: #ff6b9a;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }

/* ---------- Shell ---------- */
.wrap { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 96px); }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 0 20px; }
.top .kicker { color: var(--muted); font-size: 15px; font-weight: 600; }
.top h1 { margin: 2px 0 0; font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -.025em; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; border: 0; color: #fff; font-weight: 600; font-size: 17px;
  display: grid; place-items: center; flex: none;
}
.avatar.sm { width: 26px; height: 26px; font-size: 12px; }
h2 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 28px 4px 10px; display: flex; align-items: center; justify-content: space-between; }
h2 .link { font-size: 16px; font-weight: 500; color: var(--accent); background: none; border: 0; padding: 6px 0; }
.empty { color: var(--muted); padding: 14px 4px; font-size: 15px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 0;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--line);
}
.tabs button {
  flex: 1; max-width: 120px; border: 0; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; font-size: 11px; font-weight: 500;
}
.tabs button svg { width: 26px; height: 26px; }
.tabs button.on { color: var(--accent); }

/* ---------- Lists ---------- */
.group { background: var(--panel); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 16px; position: relative;
  width: 100%; text-align: left; background: none; border: 0;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--line); }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 500; }
.row .s { color: var(--muted); font-size: 14px; margin-top: 1px; }
.row .when { flex: none; width: 74px; color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.row.done .t { color: var(--muted); text-decoration: line-through; }
.row .chev { color: var(--muted); opacity: .5; flex: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--tint); color: var(--muted); margin-left: 6px; vertical-align: 2px; }
.tag.care { background: color-mix(in srgb, var(--care) 15%, transparent); color: var(--care); }
.tag.late { background: color-mix(in srgb, var(--late) 15%, transparent); color: var(--late); }
.tag.due { background: color-mix(in srgb, var(--warn) 18%, transparent); color: #c56a00; }
@media (prefers-color-scheme: dark) { .tag.due { color: var(--warn); } }

.check {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--muted) 55%, transparent);
  background: none; flex: none; display: grid; place-items: center; padding: 0;
}
.check svg { width: 16px; height: 16px; opacity: 0; color: #fff; }
.done .check, .check.on { background: var(--good); border-color: var(--good); }
.done .check svg, .check.on svg { opacity: 1; }

.dayhead { font-size: 15px; font-weight: 600; color: var(--muted); margin: 22px 4px 8px; }
.dayhead.today { color: var(--accent); }

.panel { background: var(--tint); border-radius: 18px; padding: 18px; }
@media (prefers-color-scheme: dark) { .panel { background: var(--panel); } }
.panel .big { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.panel .s { color: var(--muted); font-size: 15px; margin-top: 2px; }

/* ---------- Controls ---------- */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 20px;
  border-radius: 99px; border: 0; background: var(--accent); color: #fff; font-weight: 600;
}
.pill.grey { background: var(--tint); color: var(--text); }
@media (prefers-color-scheme: dark) { .pill.grey { background: #3a3a3c; } }
.pill.red { background: none; color: var(--late); }
.pill.wide { width: 100%; }
.seg { display: flex; background: rgba(118,118,128,.12); border-radius: 9px; padding: 2px; margin: 4px 0 6px; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 4px; border-radius: 7px; font-size: 14px; font-weight: 500; }
.seg button.on { background: var(--panel); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
@media (prefers-color-scheme: dark) { .seg button.on { background: #636366; } }

.addbar { display: flex; gap: 8px; margin-bottom: 12px; }
.addbar input { flex: 1; }
input[type=text], input[type=date], input[type=time], input[type=password], input[type=tel], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 12px; border: 0; background: var(--panel);
  box-shadow: inset 0 0 0 .5px var(--line); outline: none; font-size: 17px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { box-shadow: inset 0 0 0 2px var(--accent); }

/* ---------- Sheet ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease; }
.sheet {
  width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; background: var(--bg);
  border-radius: 14px 14px 0 0; padding: 8px 16px calc(env(safe-area-inset-bottom) + 20px);
  animation: up .28s cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 700px) { .scrim { align-items: center; } .sheet { border-radius: 16px; max-height: 86vh; } }
.sheet .bar { display: flex; align-items: center; justify-content: space-between; height: 52px; position: sticky; top: -8px; background: var(--bg); z-index: 1; }
.sheet .bar b { font-size: 17px; }
.sheet .bar button { background: none; border: 0; color: var(--accent); font-size: 17px; padding: 8px 0; min-width: 64px; text-align: left; }
.sheet .bar button.r { text-align: right; font-weight: 600; }
.field { margin: 14px 0; }
.field > label:not(.toggle) { display: block; font-size: 13px; color: var(--muted); margin: 0 4px 6px; font-weight: 500; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two > * { min-width: 0; }
.toggle { display: flex; align-items: center; justify-content: space-between; background: var(--panel); border-radius: 12px; padding: 10px 14px; min-height: 48px; box-shadow: inset 0 0 0 .5px var(--line); }
.toggle input { width: 50px; height: 30px; appearance: none; background: rgba(120,120,128,.24); border-radius: 99px; position: relative; transition: background .2s; flex: none; margin: 0; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .2s; }
.toggle input:checked { background: var(--good); }
.toggle input:checked::after { transform: translateX(20px); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 99px; background: var(--panel); box-shadow: inset 0 0 0 .5px var(--line); font-size: 15px; }
.chips input:checked + span { background: var(--accent); color: #fff; box-shadow: none; }
.err { color: var(--late); font-size: 15px; margin: 8px 4px; min-height: 1em; }

/* ---------- Sign in ---------- */
.signin { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 10vh) 24px 40px; text-align: center; }
.signin h1 { font-size: 34px; font-weight: 700; letter-spacing: -.03em; margin: 0 0 6px; }
.signin p { color: var(--muted); margin: 0 0 28px; }
.who { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 18px; }
.who button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 500; }
.who .avatar { width: 72px; height: 72px; font-size: 28px; }
.dots { display: flex; justify-content: center; gap: 16px; margin: 24px 0; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--text); }
.dots i.on { background: var(--text); }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px; justify-content: center; }
.pad button { width: 76px; height: 76px; border-radius: 50%; border: 0; background: rgba(118,118,128,.16); font-size: 30px; font-weight: 400; }
.pad button:active { background: rgba(118,118,128,.36); }
.pad .ghost { background: none; font-size: 16px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatches label input { position: absolute; opacity: 0; }
.swatches span { display: block; width: 36px; height: 36px; border-radius: 50%; }
.swatches input:checked + span { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--text); }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 92px); transform: translateX(-50%); background: rgba(30,30,30,.92); color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 15px; z-index: 80; animation: fade .2s ease; }

@keyframes fade { from { opacity: 0 } }
@keyframes up { from { transform: translateY(40px); opacity: .4 } }
