:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #efece6;
  --border: #e6e2da;
  --text: #1b1a17;
  --muted: #7d796f;
  --ink: #1b1a17;
  --on-ink: #ffffff;
  --hero: #1d1c23;
  --ring-day: #ff6b5b;
  --ring-week: #b8ec4f;
  --ring-month: #57cdf0;
  --high: #e5484d;
  --med: #ee9b1a;
  --low: #aaa59a;
  --missed: #d9572f;
  --good: #2fa36b;
  --radius: 20px;
  --shadow-sm: 0 1px 2px rgba(27, 26, 23, .05);
  --shadow: 0 1px 2px rgba(27, 26, 23, .04), 0 10px 28px -10px rgba(27, 26, 23, .14);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111014;
    --surface: #1a191f;
    --surface-2: #25232b;
    --border: #2e2c35;
    --text: #f3f1ec;
    --muted: #9a96a2;
    --ink: #f3f1ec;
    --on-ink: #111014;
    --hero: #1c1b23;
    --low: #6e6a76;
    --missed: #ff8a65;
    --good: #3fb67b;
    --shadow-sm: none;
    --shadow: 0 10px 28px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ring-month); outline-offset: 2px; }

.app { max-width: 580px; margin: 0 auto; padding: 28px 16px 56px; }

.sample-bar {
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.sample-bar a { color: var(--text); font-weight: 700; }

/* Hero card: date + score rings */
.hero {
  margin-bottom: 14px;
  padding: 22px 22px 24px;
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 28px;
  background:
    radial-gradient(280px 180px at 100% 0%, rgba(255, 107, 91, .22), transparent 70%),
    radial-gradient(280px 180px at 0% 100%, rgba(87, 205, 240, .14), transparent 70%),
    var(--hero);
  color: #fff;
  box-shadow: 0 24px 48px -24px rgba(29, 28, 35, .55);
}
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.eyebrow { margin: 0; color: rgba(255, 255, 255, .6); font-size: 14px; font-weight: 500; }
h1 {
  margin: 6px 0 24px;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.025em;
}
.nav { display: flex; gap: 6px; }
.nav-btn {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 99px;
  background: rgba(255, 255, 255, .06);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  transition: background-color .15s;
}
.nav-btn.pill { padding: 0 14px; }
.nav-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .14); }
.nav-btn:disabled { opacity: .35; cursor: default; }

.scores { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.score { --ring: var(--ring-day); display: flex; flex-direction: column; align-items: center; text-align: center; }
#scoreWeek { --ring: var(--ring-week); }
#scoreMonth { --ring: var(--ring-month); }
.ring-wrap { position: relative; width: 88px; height: 88px; margin-bottom: 10px; }
.ring { display: block; width: 100%; height: 100%; overflow: visible; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring-track { stroke: rgba(255, 255, 255, .09); }
.ring-fill {
  stroke: var(--ring);
  stroke-linecap: round;
  stroke-dasharray: 213.63; /* 2πr, r = 34 */
  stroke-dashoffset: 213.63;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--ring) 50%, transparent));
  transition: stroke-dashoffset .8s cubic-bezier(.2, .8, .2, 1);
}
.score.zero .ring-fill { opacity: 0; }
.score-pct {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.02em;
}
.score.complete .score-pct { color: var(--ring); }
.score-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.score-label::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ring); }
.score-sub { color: rgba(255, 255, 255, .55); font-size: 12px; }

/* Week strip */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 14px; }
.day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0 9px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  transition: transform .15s, background-color .15s;
}
.day:hover { transform: translateY(-2px); }
.dow { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.num { font-size: 17px; font-weight: 700; line-height: 1.2; }
.day.today .num { color: var(--ring-day); }
.day.selected { border-color: var(--ink); background: var(--ink); color: var(--on-ink); }
.day.selected .dow { color: color-mix(in srgb, var(--on-ink) 60%, transparent); }
.dot { width: 6px; height: 6px; border-radius: 50%; }
.dot.pending { background: var(--border); }
.day.selected .dot.pending { background: color-mix(in srgb, var(--on-ink) 30%, transparent); }
.dot.partial { background: var(--med); }
.dot.complete { background: var(--good); }

/* Add form */
.add {
  margin-bottom: 14px;
  padding: 8px 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
.add:focus-within { border-color: color-mix(in srgb, var(--ink) 40%, transparent); }
.add-row { display: flex; align-items: center; gap: 8px; }
#taskInput {
  flex: 1;
  min-width: 0;
  padding: 10px;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 16px;
  font-weight: 500;
}
#taskInput::placeholder { color: var(--muted); font-weight: 400; }
.add-btn {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: var(--ink);
  color: var(--on-ink);
  transition: transform .15s;
}
.add-btn:hover { transform: scale(1.05); }
.add-btn:active { transform: scale(.95); }
.add-options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 4px 0; }

.seg, .tabs { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-2); }
.seg label, .toggle { position: relative; cursor: pointer; }
.seg input, .toggle input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: background-color .15s, color .15s;
}
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span,
.toggle input:focus-visible + span { outline: 2px solid var(--ring-month); outline-offset: 1px; }
.pdot { width: 8px; height: 8px; border-radius: 50%; }
.pdot.high { background: var(--high); }
.pdot.med { background: var(--med); }
.pdot.low { background: var(--low); }
.toggle span {
  display: block;
  padding: 6px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: background-color .15s, color .15s;
}
.toggle input:checked + span { border: 1px solid var(--ink); background: var(--ink); color: var(--on-ink); }

/* Missed tasks */
.missed-box {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--missed) 25%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--missed) 8%, var(--bg));
}
.missed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 2px 4px 0;
}
.missed-title { display: flex; align-items: center; gap: 8px; color: var(--missed); font-size: 14px; font-weight: 700; }
.missed-box .link-btn { color: var(--missed); }

/* List header */
.list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin: 22px 0 12px;
}
[data-filter] {
  padding: 6px 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
[data-filter].active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tab-count {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--missed) 15%, transparent);
  color: var(--missed);
  font-size: 11px;
  font-weight: 700;
}
.tab-count:empty { display: none; }
.link-btn {
  padding: 4px;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
  text-underline-offset: 3px;
}
.link-btn:hover { text-decoration-color: currentColor; }
.link-btn:disabled { color: var(--muted); opacity: .5; cursor: default; text-decoration: none; }

/* Tasks */
.list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 4px 2px;
  font-size: 13px;
  font-weight: 700;
}
.group-head:first-child { padding-top: 0; }
.group-count { color: var(--missed); font-size: 12px; font-weight: 600; }
.task {
  --prio: var(--low);
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  padding: 10px 8px 10px 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
}
.task:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.task.p-high { --prio: var(--high); }
.task.p-med { --prio: var(--med); }
.task.done { background: color-mix(in srgb, var(--surface) 50%, transparent); box-shadow: none; }
.task.enter { animation: rise .35s cubic-bezier(.2, .8, .2, 1); }

.task input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  display: grid;
  place-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin: 0;
  border: 2px solid var(--prio);
  border-radius: 50%;
  background: color-mix(in srgb, var(--prio) 10%, transparent);
  cursor: pointer;
}
.task input[type="checkbox"]::after {
  content: "";
  width: 10px;
  height: 5px;
  border: solid #fff;
  border-width: 0 0 2px 2px;
  transform: translateY(-1px) rotate(-45deg);
  opacity: 0;
}
.task input[type="checkbox"]:checked { border-color: var(--good); background: var(--good); }
.task input[type="checkbox"]:checked::after { opacity: 1; }
.task.pop input[type="checkbox"] { animation: pop .35s cubic-bezier(.3, 1.6, .5, 1); }

.task-main {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
}
.title { flex: 1 1 140px; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.task.done .title {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent);
}
.edit {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--ink);
  border-radius: 10px;
  outline: none;
  background: var(--surface);
  font-weight: 500;
}

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.high { background: color-mix(in srgb, var(--high) 12%, transparent); color: var(--high); }
.badge.missed { background: color-mix(in srgb, var(--missed) 13%, transparent); color: var(--missed); }
.task.done .badge.missed { background: var(--surface-2); color: var(--muted); }

.actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.task:hover .actions, .task:focus-within .actions { opacity: 1; }
@media (hover: none) { .actions { opacity: 1; } }
.actions button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
}
.actions button:hover { background: var(--surface-2); color: var(--text); }
.actions .del:hover { color: var(--high); }

.empty { margin: 0; padding: 36px 0 20px; color: var(--muted); text-align: center; }
.empty::before {
  content: "";
  display: block;
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a9a397' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 22px no-repeat;
}
.hint { margin-top: 12px; color: var(--muted); font-size: 12px; text-align: center; }

/* Account bar + sync status */
.account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 14px;
  margin-top: 32px;
  color: var(--muted);
  font-size: 13px;
}
.account b { color: var(--text); font-weight: 700; }
.sync { display: inline-flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--low); }
.sync.synced::before { background: var(--good); }
.sync.saving::before { background: var(--med); }
.sync.offline::before, .sync.error::before { background: var(--missed); }
.local-note { margin: 32px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

/* Login screen */
.auth { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }
.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 28px 24px 24px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}
.auth-logo { display: block; margin: 0 auto 14px; border-radius: 18px; }
.auth-title { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.auth-sub { margin: 6px 0 20px; color: var(--muted); font-size: 14px; }
.field { display: block; margin-bottom: 12px; text-align: left; }
.field span { display: block; margin: 0 0 5px 2px; color: var(--muted); font-size: 13px; font-weight: 600; }
.field input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  background: var(--bg);
  font-size: 16px;
}
.field input:focus { border-color: var(--ink); }
.auth-error {
  margin: 4px 0 12px;
  padding: 8px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--high) 12%, transparent);
  color: var(--high);
  font-size: 13px;
  font-weight: 600;
}
.auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  border: 0;
  border-radius: 14px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 15px;
  font-weight: 700;
}
.auth-btn:disabled { opacity: .6; cursor: default; }
.lock-alt { margin-top: 14px; color: var(--muted); }

@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes pop { from { transform: scale(.6); } }

@media (max-width: 420px) {
  .hero { padding: 18px 16px 20px; border-radius: 24px; }
  h1 { margin-bottom: 20px; font-size: 25px; }
  .ring-wrap { width: 76px; height: 76px; }
  .score-pct { font-size: 17px; }
  .seg span { padding: 5px 8px; }
  [data-filter] { padding: 6px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
