/* Home List v2 — direction: DESIGN.md (Mel) */
:root {
  --bg: #F2F2F5;
  --surface: #FFFFFF;
  --surface-2: #F5F5F8;
  --ink: #0B0B0F;
  --ink-2: #6B6B76;
  --ink-3: #A1A1AA;
  --line: rgba(0, 0, 0, .07);
  --fill: rgba(118, 118, 128, .12);
  --fill-2: rgba(118, 118, 128, .2);
  --primary: #0B0B0F;
  --on-primary: #FFFFFF;
  --done: #2E9E62;
  --going: #D98A0B;
  --urgent: #E5484D;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.14);
  --header-bg: rgba(242, 242, 245, .78);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1C1C1E;
    --surface-2: #2C2C2E;
    --ink: #F5F5F7;
    --ink-2: #98989F;
    --ink-3: #636369;
    --line: rgba(255, 255, 255, .09);
    --fill: rgba(118, 118, 128, .24);
    --fill-2: rgba(118, 118, 128, .36);
    --primary: #F5F5F7;
    --on-primary: #0B0B0F;
    --done: #3DD68C;
    --going: #F5B83D;
    --urgent: #FF6369;
    --shadow: none;
    --shadow-lg: 0 10px 40px rgba(0,0,0,.6);
    --header-bg: rgba(0, 0, 0, .72);
    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: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; min-height: 100dvh;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header ---------- */
.header {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-t) + 10px) 20px 10px;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid transparent; transition: border-color .2s;
}
.header.scrolled { border-bottom-color: var(--line); }
.topline { display: flex; align-items: center; justify-content: space-between; min-height: 36px; }
.mini-title { font-weight: 600; font-size: 17px; opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .2s; }
.header.scrolled .mini-title { opacity: 1; transform: none; }
.eyebrow { color: var(--ink-2); font-size: 15px; font-weight: 500; margin: 6px 0 0; }
.title { font-size: 34px; font-weight: 700; letter-spacing: -.022em; margin: 0 0 14px; line-height: 1.1; }

.avatar {
  --c: #888; display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--c); color: #fff; font-weight: 650; font-size: 15px; letter-spacing: -.01em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.avatar.sm { width: 22px; height: 22px; font-size: 11px; }
.avatar.lg { width: 44px; height: 44px; font-size: 18px; }
.avatar.all { background: var(--fill-2); color: var(--ink); }
.avatar.all svg { width: 20px; height: 20px; }

/* ---------- Segmented control ---------- */
.segmented {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 2px;
  background: var(--fill); border-radius: 10px; position: relative;
}
.segmented button {
  height: 32px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--ink);
  display: flex; align-items: center; justify-content: center; gap: 6px; transition: background .18s, box-shadow .18s;
}
.segmented button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 0 0 .5px rgba(0,0,0,.04); }
@media (prefers-color-scheme: dark) { .segmented button[aria-pressed="true"] { background: #636366; } }
.count { font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 500; }

/* ---------- People chips (parents) ---------- */
.people {
  display: flex; gap: 14px; overflow-x: auto; padding: 16px 20px 6px; margin: 0 -20px;
  scrollbar-width: none; scroll-snap-type: x proximity; scroll-padding-inline: 20px;
}
.people::-webkit-scrollbar { display: none; }
.person {
  display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 52px;
  font-size: 12px; font-weight: 500; color: var(--ink-2); scroll-snap-align: start; position: relative;
}
.person .avatar { width: 48px; height: 48px; font-size: 18px; transition: transform .15s, box-shadow .15s; }
.person[aria-pressed="true"] { color: var(--ink); font-weight: 650; }
.person[aria-pressed="true"] .avatar { box-shadow: 0 0 0 2.5px var(--bg), 0 0 0 4.5px var(--ink); }
.person:active .avatar { transform: scale(.94); }
.badge {
  position: absolute; top: -3px; right: 0; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--ink); color: var(--bg);
  font-size: 12px; font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--bg);
}

/* ---------- List ---------- */
main { padding: 8px 16px calc(var(--safe-b) + 120px); max-width: 680px; margin: 0 auto; }
.header-inner { max-width: 648px; margin: 0 auto; }
.section-h {
  display: flex; align-items: center; gap: 8px;
  margin: 22px 8px 8px; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2);
}
.section-h .avatar { margin-right: 2px; }
.section-h .n { margin-left: auto; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.group { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; min-height: 60px;
  position: relative; width: 100%; text-align: left; transition: background .15s, opacity .22s, transform .22s;
}
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: 52px; border-top: .5px solid var(--line); }
.row.no-check + .row::before, .row.no-check::before { left: 16px; }
.row-main { flex: 1; min-width: 0; display: block; text-align: left; padding: 2px 0; }
.row-main:active { opacity: .6; }
.row-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 17px; letter-spacing: -.01em; }
.row-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 14px; color: var(--ink-2); min-width: 0; }
.row-meta .notes { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-3); flex: none; }
.urgent-tag {
  flex: none; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--urgent); background: color-mix(in srgb, var(--urgent) 12%, transparent);
  padding: 3px 7px; border-radius: 6px; font-style: normal;
}
.row.done .row-title span { color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--ink-3); }
.row.leaving { opacity: 0; transform: translateX(16px); }

.check {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--ink-3); display: grid; place-items: center; transition: all .18s;
}
.check svg { width: 14px; height: 14px; opacity: 0; transform: scale(.5); transition: all .18s; color: #fff; }
.check.going { border-color: var(--going); background: color-mix(in srgb, var(--going) 14%, transparent); }
.check.going::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--going); }
.check.on { border-color: var(--done); background: var(--done); }
.check.on svg { opacity: 1; transform: none; }
.check:active { transform: scale(.88); }

.pill {
  flex: none; font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 999px;
  background: var(--fill); color: var(--ink-2); white-space: nowrap;
}
.pill.going { color: var(--going); background: color-mix(in srgb, var(--going) 14%, transparent); }
.pill.done { color: var(--done); background: color-mix(in srgb, var(--done) 14%, transparent); }
.chev { color: var(--ink-3); flex: none; width: 8px; }

.empty { text-align: center; padding: 72px 24px 40px; color: var(--ink-2); }
.empty-ic {
  width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 16px; display: grid; place-items: center;
  background: var(--surface); box-shadow: var(--shadow); color: var(--ink-3);
}
.empty-ic svg { width: 30px; height: 30px; }
.empty h2 { color: var(--ink); font-size: 20px; margin: 0 0 6px; letter-spacing: -.01em; }
.empty p { margin: 0; font-size: 15px; }

.banner {
  margin: 12px 4px 0; padding: 12px 14px; border-radius: 14px; font-size: 15px;
  background: color-mix(in srgb, var(--urgent) 12%, var(--surface)); color: var(--ink);
  display: flex; gap: 10px; align-items: center;
}
.banner button { margin-left: auto; font-weight: 600; color: var(--urgent); }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: max(20px, calc(50vw - 320px)); bottom: calc(var(--safe-b) + 24px); z-index: 30;
  height: 56px; padding: 0 22px 0 18px; border-radius: 28px;
  background: var(--primary); color: var(--on-primary);
  display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 17px;
  box-shadow: var(--shadow-lg); transition: transform .15s;
}
.fab svg { width: 22px; height: 22px; }
.fab:active { transform: scale(.96); }

/* ---------- Sheet ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 40; animation: fade .2s ease-out; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; margin: 0 auto; max-width: 640px;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 8px 20px calc(var(--safe-b) + 20px);
  max-height: 92dvh; overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: up .24s cubic-bezier(.2,.8,.2,1);
}
@media (prefers-color-scheme: dark) { .sheet { background: #1C1C1E; } }
.grab { width: 38px; height: 5px; border-radius: 3px; background: var(--fill-2); margin: 0 auto 10px; }
.sheet-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; min-height: 40px; }
.sheet-top h2 { font-size: 17px; font-weight: 650; margin: 0; }
.link-btn { color: var(--ink-2); font-size: 17px; padding: 8px 0; }
.big-input {
  width: 100%; border: 0; outline: 0; background: transparent;
  font-size: 26px; font-weight: 650; letter-spacing: -.02em; padding: 8px 0 12px;
}
.big-input::placeholder { color: var(--ink-3); }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 14px 0 8px; letter-spacing: .02em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 36px; padding: 0 14px; border-radius: 18px; background: var(--fill);
  font-size: 15px; font-weight: 550; display: inline-flex; align-items: center; gap: 6px; transition: all .15s;
}
.chip[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.chip .avatar { width: 22px; height: 22px; font-size: 11px; margin-left: -6px; }
.textarea {
  width: 100%; min-height: 76px; resize: none; border: 0; outline: 0;
  background: var(--fill); border-radius: 14px; padding: 12px 14px; font-size: 16px; line-height: 1.4;
}
.textarea::placeholder { color: var(--ink-3); }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 14px; padding: 12px 14px; background: var(--fill); border-radius: 14px;
}
.toggle-row b { font-weight: 600; display: block; }
.toggle-row small { color: var(--ink-2); font-size: 13px; }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: var(--fill-2); transition: background .2s; }
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: transform .2s;
}
.switch input:checked + span { background: var(--urgent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }

.primary-btn {
  width: 100%; height: 54px; border-radius: 16px; margin-top: 20px;
  background: var(--primary); color: var(--on-primary); font-size: 17px; font-weight: 650;
  transition: opacity .15s, transform .15s;
}
.primary-btn:disabled { opacity: .35; }
.primary-btn:active:not(:disabled) { transform: scale(.985); }
.form-error { color: var(--urgent); font-size: 14px; margin-top: 10px; }

.detail-head { display: flex; gap: 14px; align-items: flex-start; margin: 4px 0 18px; }
.detail-head h3 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; overflow-wrap: anywhere; }
.detail-head p { margin: 4px 0 0; color: var(--ink-2); font-size: 15px; }
.detail-notes { background: var(--fill); border-radius: 14px; padding: 12px 14px; font-size: 16px; margin-bottom: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.actions { background: var(--surface-2); border-radius: 16px; overflow: hidden; }
@media (prefers-color-scheme: dark) { .actions { background: #2C2C2E; } }
.action {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 15px 16px; font-size: 17px; font-weight: 500;
  position: relative; text-align: left;
}
.action + .action::before { content: ""; position: absolute; top: 0; left: 54px; right: 0; border-top: .5px solid var(--line); }
.action svg { width: 22px; height: 22px; flex: none; }
.action:active { background: var(--fill); }
.action.danger { color: var(--urgent); }
.action .ic-done { color: var(--done); }
.action .ic-going { color: var(--going); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 96px); z-index: 60;
  transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px);
  background: var(--primary); color: var(--on-primary); border-radius: 14px;
  padding: 12px 8px 12px 16px; display: flex; align-items: center; gap: 16px;
  font-size: 15px; font-weight: 500; box-shadow: var(--shadow-lg); animation: pop .2s ease-out;
}
.toast button { font-weight: 700; padding: 4px 10px; color: inherit; opacity: .9; }
.toast.plain { padding-right: 16px; }

/* ---------- Locked / loading ---------- */
.center { min-height: 100dvh; display: grid; place-items: center; padding: 32px 24px; text-align: center; }
.lock-card { max-width: 360px; }
.app-icon { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 20px; box-shadow: var(--shadow-lg); display: block; }
.lock-card h1 { font-size: 28px; letter-spacing: -.02em; margin: 0 0 8px; }
.lock-card p { color: var(--ink-2); margin: 0 0 6px; font-size: 16px; }
.skeleton { height: 60px; border-radius: 12px; background: var(--fill); margin: 10px 0; animation: pulse 1.2s ease-in-out infinite; }

.install-tip {
  margin: 16px 4px 0; padding: 14px 16px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow);
  display: flex; gap: 12px; align-items: flex-start; font-size: 15px;
}
.install-tip svg { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.install-tip p { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; }
.install-tip button { margin-left: auto; color: var(--ink-3); padding: 2px; }

.me-sheet { text-align: center; padding: 8px 0 4px; }
.me-sheet .avatar { width: 72px; height: 72px; font-size: 28px; margin-bottom: 12px; }
.me-sheet h3 { margin: 0; font-size: 22px; }
.me-sheet p { color: var(--ink-2); margin: 6px 0 0; font-size: 15px; }

@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes pulse { 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
