/* ============================================================
   Clean - mobile-first chore checklist
   Calm, warm, one-thing-at-a-time. Dark mode aware.
   ============================================================ */

:root {
  --accent: #7c5cff;
  --accent-2: #2dd4bf;
  --accent-grad: linear-gradient(135deg, #7c5cff, #2dd4bf);
  --bg: #f7f5fb;
  --bg-soft: #efeaf7;
  --card: #ffffff;
  --card-2: #faf8ff;
  --text: #211d2e;
  --text-soft: #6b6680;
  --text-faint: #9a95ab;
  --line: #ece8f3;
  --line-strong: #ded8ec;
  --good: #22c08b;
  --warn: #f5a623;
  --danger: #ef5d77;
  --shadow: 0 6px 22px rgba(60, 40, 110, .08);
  --shadow-lg: 0 14px 40px rgba(60, 40, 110, .18);
  --radius: 18px;
  --radius-sm: 12px;
  --tap: 48px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;
  font-size: 16px;
}

html[data-theme="dark"] {
  --accent: #9b82ff;
  --accent-2: #3fe0cb;
  --bg: #15131c;
  --bg-soft: #1d1a28;
  --card: #221f30;
  --card-2: #272336;
  --text: #f1eefb;
  --text-soft: #b3aecb;
  --text-faint: #7d789b;
  --line: #2e2a3e;
  --line-strong: #393450;
  --good: #36d39a;
  --warn: #f7b955;
  --danger: #ff6f88;
  --shadow: 0 6px 22px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 44px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
input, select, textarea, button { font-size: 16px; }

#app { display: flex; flex-direction: column; min-height: 100dvh; }

/* ---------- Top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 30;
  padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--accent-grad);
  box-shadow: var(--shadow);
  position: relative; flex: none;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 0;
  background:
    no-repeat center/58% url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="none" stroke="white" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4 10-11"/></svg>');
}
.brand-text h1 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.brand-text p { font-size: .72rem; color: var(--text-soft); margin-top: 1px; }
.icon-btn {
  width: var(--tap); height: var(--tap); border: none; border-radius: 50%;
  background: transparent; color: var(--text-soft);
  display: grid; place-items: center;
}
.icon-btn:active { background: var(--bg-soft); }

/* ---------- View container ---------- */
#view {
  flex: 1;
  width: 100%; max-width: 720px; margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
}

/* ---------- Bottom tab bar ---------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around;
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; border: none; background: none; color: var(--text-faint);
  height: var(--tabbar-h); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  font-size: .66rem; font-weight: 600; letter-spacing: .01em;
  transition: color .15s;
}
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--accent); }
.tab.active svg { transform: translateY(-1px); }

/* ---------- Cards & generic ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: .72rem; font-weight: 600;
  background: var(--bg-soft); color: var(--text-soft);
}
.section-title { font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-faint); margin: 18px 4px 8px; }
.empty { text-align: center; color: var(--text-faint); padding: 40px 16px; }
.empty .big { font-size: 2.4rem; margin-bottom: 8px; }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: 12px; padding: 0 18px; height: var(--tap);
  font-weight: 700; font-size: .95rem; color: #fff; background: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(.98); }
.btn.grad { background: var(--accent-grad); }
.btn.block { width: 100%; }
.btn.ghost { background: var(--bg-soft); color: var(--text); }
.btn.danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.btn.sm { height: 38px; padding: 0 12px; font-size: .85rem; border-radius: 10px; }

/* ---------- Today: hero / progress ---------- */
.day-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.day-nav .arrow {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--text-soft); display: grid; place-items: center;
}
.day-nav .day-label { text-align: center; }
.day-nav .day-label b { font-size: 1.15rem; }
.day-nav .day-label span { display: block; font-size: .76rem; color: var(--text-soft); }

.hero {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px; display: flex; align-items: center; gap: 18px;
}
.ring { position: relative; width: 92px; height: 92px; flex: none; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring .track { stroke: var(--line); }
.ring .meter { stroke: url(#ringGrad); stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1); }
.ring .label { position: absolute; inset: 0; display: grid; place-items: center; }
.ring .label b { font-size: 1.5rem; line-height: 1; }
.ring .label small { font-size: .62rem; color: var(--text-soft); }
.hero-msg h2 { font-size: 1.15rem; font-weight: 750; letter-spacing: -.01em; }
.hero-msg p { color: var(--text-soft); font-size: .85rem; margin-top: 3px; }
.hero-msg .meta { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Filter chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line-strong); background: var(--card);
  color: var(--text-soft); border-radius: 999px; padding: 8px 14px;
  font-size: .82rem; font-weight: 600; display: inline-flex; align-items: center; gap: 6px;
}
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; }

/* ---------- Category groups / checklist ---------- */
.group { margin-bottom: 12px; }
.group-head {
  display: flex; align-items: center; gap: 10px; padding: 6px 4px;
  cursor: pointer; user-select: none;
}
.group-head .chev { color: var(--text-faint); transition: transform .2s; }
.group.collapsed .chev { transform: rotate(-90deg); }
.group-head h3 { font-size: .92rem; font-weight: 700; }
.group-head .count { margin-left: auto; font-size: .76rem; color: var(--text-faint); font-weight: 600; }
.group.collapsed .list { display: none; }

.list { display: flex; flex-direction: column; gap: 8px; }
.task {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 12px 12px 12px 14px; position: relative; overflow: hidden;
  border-left: 4px solid transparent;
}
.task .check {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  border: 2.5px solid var(--line-strong); background: var(--card);
  display: grid; place-items: center; color: #fff; transition: .18s;
}
.task .check svg { width: 16px; height: 16px; opacity: 0; transform: scale(.4); transition: .18s; }
.task .body { flex: 1; min-width: 0; }
.task .body .t { font-weight: 650; font-size: .96rem; line-height: 1.25; }
.task .body .sub { display: flex; gap: 8px; align-items: center; margin-top: 3px; flex-wrap: wrap; }
.task .body .sub span { font-size: .73rem; color: var(--text-faint); display: inline-flex; align-items: center; gap: 4px; }
.task .more {
  width: 38px; height: 38px; border-radius: 10px; border: none; background: transparent;
  color: var(--text-faint); display: grid; place-items: center; flex: none;
}
.task .more:active { background: var(--bg-soft); }
.task.done .check { background: var(--good); border-color: var(--good); }
.task.done .check svg { opacity: 1; transform: scale(1); }
.task.done .body .t { color: var(--text-faint); text-decoration: line-through; }
.task.skipped { opacity: .55; }
.task.skipped .body .t { text-decoration: line-through; }
.task.prio-2 { border-left-color: var(--warn); }
.task.flash { animation: flash .5s ease; }
@keyframes flash { 0% { background: color-mix(in srgb, var(--good) 22%, var(--card)); } 100% { background: var(--card); } }

.avatar {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: .7rem; color: #fff; font-weight: 700;
}
.avatar.lg { width: 44px; height: 44px; font-size: 1.1rem; }

/* overdue banner */
.overdue-card { border: 1px dashed var(--line-strong); background: var(--card-2); }
.overdue-card .group-head h3 { color: var(--warn); }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-head b { font-size: 1.1rem; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.cal-dow span { text-align: center; font-size: .68rem; color: var(--text-faint); font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  aspect-ratio: 1 / 1.15; border-radius: 12px; background: var(--card);
  box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center;
  padding: 6px 2px 4px; position: relative; border: 1.5px solid transparent;
}
.cal-cell.out { opacity: .32; }
.cal-cell.today { border-color: var(--accent); }
.cal-cell .num { font-size: .82rem; font-weight: 650; }
.cal-cell.done-all .num { color: var(--good); }
.cal-cell .dots { display: flex; gap: 3px; margin-top: auto; flex-wrap: wrap; justify-content: center; max-width: 100%; }
.cal-cell .dots i { width: 5px; height: 5px; border-radius: 50%; }
.cal-cell .cnt { position: absolute; top: 4px; right: 6px; font-size: .58rem; color: var(--text-faint); font-weight: 700; }
.cal-cell .ring-mini { position: absolute; bottom: 5px; }
.cal-legend { display: flex; gap: 14px; justify-content: center; margin-top: 14px; font-size: .73rem; color: var(--text-soft); }
.cal-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }

/* ---------- Tasks manage ---------- */
.task-def {
  background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 12px 14px; display: flex; gap: 12px; align-items: center; margin-bottom: 8px;
}
.task-def.inactive { opacity: .5; }
.task-def .body { flex: 1; min-width: 0; }
.task-def .body .t { font-weight: 650; }
.task-def .body .sub { font-size: .74rem; color: var(--text-faint); margin-top: 2px; }
.task-def .next { font-size: .72rem; color: var(--text-soft); text-align: right; flex: none; }

.fab {
  position: fixed; right: 18px; z-index: 35;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  width: 58px; height: 58px; border-radius: 50%; border: none; color: #fff;
  background: var(--accent-grad); box-shadow: var(--shadow-lg);
  display: grid; place-items: center;
}
.fab svg { width: 28px; height: 28px; }
.fab:active { transform: scale(.94); }

/* ---------- People ---------- */
.person {
  background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 12px 14px; display: flex; align-items: center; gap: 14px; margin-bottom: 8px;
}
.person .body { flex: 1; }
.person .body .n { font-weight: 700; }
.person .body .s { font-size: .76rem; color: var(--text-soft); margin-top: 2px; }
.loadbar { height: 7px; border-radius: 6px; background: var(--line); overflow: hidden; margin-top: 7px; }
.loadbar i { display: block; height: 100%; border-radius: 6px; }

/* ---------- Insights ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.stat {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; text-align: center;
}
.stat .v { font-size: 2rem; font-weight: 800; line-height: 1; background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat .l { font-size: .76rem; color: var(--text-soft); margin-top: 6px; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding: 8px 0; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .b .col { width: 70%; min-height: 4px; border-radius: 6px 6px 3px 3px; background: var(--accent-grad); transition: height .5s; }
.bars .b .lab { font-size: .64rem; color: var(--text-faint); font-weight: 700; }
.bars .b .pct { font-size: .6rem; color: var(--text-faint); }

/* ---------- Sheets / modals ---------- */
#sheet-root:empty { display: none; }
.scrim {
  position: fixed; inset: 0; z-index: 50; background: rgba(20, 12, 40, .42);
  backdrop-filter: blur(2px); display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  background: var(--bg); width: 100%; max-width: 560px;
  border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  max-height: 92dvh; display: flex; flex-direction: column;
  animation: slideup .26s cubic-bezier(.2,.8,.2,1);
  padding-bottom: var(--safe-bottom);
}
@keyframes slideup { from { transform: translateY(100%); } }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 8px; position: sticky; top: 0;
}
.sheet-head .grip { position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
  width: 38px; height: 4px; border-radius: 3px; background: var(--line-strong); }
.sheet-head h2 { font-size: 1.1rem; font-weight: 750; }
.sheet-body { overflow-y: auto; padding: 6px 18px 18px; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 12px 18px calc(14px + var(--safe-bottom)); border-top: 1px solid var(--line);
  display: flex; gap: 10px; }
.close-x { width: 36px; height: 36px; border-radius: 50%; border: none; background: var(--bg-soft);
  color: var(--text-soft); display: grid; place-items: center; font-size: 1.1rem; }

/* action sheet list */
.action {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--card); border: none; border-radius: 12px; padding: 14px 16px;
  margin-bottom: 8px; color: var(--text); font-size: .95rem; font-weight: 600;
  box-shadow: var(--shadow);
}
.action:active { background: var(--card-2); }
.action svg { width: 22px; height: 22px; color: var(--text-soft); flex: none; }
.action.danger { color: var(--danger); }
.action.danger svg { color: var(--danger); }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: .78rem; font-weight: 700; color: var(--text-soft); margin-bottom: 6px; }
.input, .select, textarea.input {
  width: 100%; border: 1.5px solid var(--line-strong); border-radius: 12px;
  background: var(--card); color: var(--text); padding: 12px 13px; outline: none;
  transition: border-color .15s;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 64px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button, .wd button, .opt {
  border: 1.5px solid var(--line-strong); background: var(--card); color: var(--text-soft);
  border-radius: 10px; padding: 9px 12px; font-weight: 650; font-size: .85rem; flex: 1;
}
.seg button.active, .wd button.active, .opt.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.wd { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.wd button { padding: 9px 0; flex: none; font-size: .76rem; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; }
.swatch.active { border-color: var(--text); }
.emoji-row { display: flex; gap: 6px; flex-wrap: wrap; }
.emoji-pick { width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--line-strong);
  background: var(--card); font-size: 1.2rem; }
.emoji-pick.active { border-color: var(--accent); background: var(--bg-soft); }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.switch { width: 50px; height: 30px; border-radius: 999px; background: var(--line-strong); position: relative;
  border: none; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch.on { background: var(--good); }
.switch.on::after { left: 23px; }
.hint { font-size: .74rem; color: var(--text-faint); margin-top: 5px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 18px); z-index: 60;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 999px;
  font-size: .85rem; font-weight: 600; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: .25s; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Confetti ---------- */
#confetti { position: fixed; inset: 0; z-index: 55; pointer-events: none; display: none; }
#confetti.go { display: block; }

/* ---------- Misc ---------- */
.skeleton { background: linear-gradient(90deg, var(--bg-soft), var(--card), var(--bg-soft));
  background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 12px; height: 64px; margin-bottom: 8px; }
@keyframes sk { to { background-position: -200% 0; } }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
a { color: var(--accent); }
