:root {
  --bg: #f8f3ec; --surface: #fffdf9; --surface-2: #efe7dc; --line: #e4d9ca;
  --ink: #22212b; --muted: #746e70; --accent: #d2552a; --accent-ink: #fff; --accent-soft: #f9dfd3;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15151c; --surface: #1f1f29; --surface-2: #2a2a36; --line: #353542;
    --ink: #f0ecec; --muted: #a7a2a6; --accent: #ef7b4e; --accent-ink: #231108; --accent-soft: #43261b;
  }
}
.c-ember { --c: #d2552a; } .c-sea { --c: #14857f; } .c-plum { --c: #7a4bb5; }
.c-moss { --c: #5b8c2e; } .c-sky { --c: #2d7fd1; } .c-rose { --c: #cf3f74; }
@media (prefers-color-scheme: dark) {
  .c-ember { --c: #ef7b4e; } .c-sea { --c: #3cbfb6; } .c-plum { --c: #ad86e6; }
  .c-moss { --c: #93c75a; } .c-sky { --c: #6cb2f3; } .c-rose { --c: #ef7aa3; }
}

.small { font-size: 13px; }
.wide { width: 100%; }
.shell { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.page > div { display: grid; gap: 16px; padding: 18px 16px 24px; }
.offline { padding: 9px 16px; background: var(--warn-soft); font-size: 14px; font-weight: 700; }

.tabs {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr);
  max-width: 560px; margin: 0 auto; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
@media (min-width: 561px) { .tabs { border: 1px solid var(--line); border-bottom: 0; border-radius: 14px 14px 0 0; } }
.tab { display: grid; justify-items: center; gap: 2px; padding: 5px 2px; border-radius: 10px; font-size: 12px; font-weight: 700; color: var(--muted); text-decoration: none; }
.tab.active { color: var(--accent); background: var(--accent-soft); }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.today-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; min-height: 84px; }
.date::first-letter { text-transform: uppercase; }
.ring { position: relative; width: 80px; height: 80px; flex: none; }
.ring svg { width: 100%; height: 100%; display: block; }
.ring circle { fill: none; stroke-width: 8; }
.ring-bg { stroke: var(--surface-2); }
.ring-value { stroke: var(--accent); stroke-linecap: round; transition: stroke-dasharray .25s; }
.ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.05; }
.ring-text b { font-size: 21px; font-weight: 800; }
.ring-text span { font-size: 11px; color: var(--muted); font-weight: 700; }

.habits { display: grid; gap: 10px; }
.habit { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.habit.done { background: color-mix(in srgb, var(--c) 9%, var(--surface)); border-color: color-mix(in srgb, var(--c) 34%, var(--line)); }
.habit-main { flex: 1; min-width: 0; display: grid; padding: 6px 0; text-decoration: none; }
.habit-title { font-size: 16px; font-weight: 800; overflow-wrap: break-word; }
.habit-meta { font-size: 13px; color: var(--muted); font-weight: 600; }
.mark {
  flex: none; width: 52px; height: 52px; display: grid; place-items: center; padding: 0; cursor: pointer;
  background: transparent; border: 3px solid color-mix(in srgb, var(--c) 42%, var(--line)); border-radius: 50%;
  transition: background .15s, transform .15s;
}
.mark:active { transform: scale(.92); }
.check-icon { width: 26px; height: 26px; fill: none; stroke: transparent; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.mark[aria-pressed=true] { background: var(--c); border-color: var(--c); }
.mark[aria-pressed=true] .check-icon { stroke: var(--surface); }

.habit-head, .month-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.habit-hero { display: grid; gap: 3px; }
.habit-hero h1 { color: var(--c); overflow-wrap: break-word; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; }
.metric { display: grid; gap: 1px; align-content: start; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
.metric b { font-size: 25px; font-weight: 800; line-height: 1.15; }
.metric span { font-size: 12.5px; color: var(--muted); font-weight: 600; overflow-wrap: break-word; }

.panel { display: grid; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.month-head h2 { text-transform: capitalize; }
.month-head .btn { min-width: 44px; padding: 8px; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.weekday { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.weekday.now { color: var(--accent); }
.day { aspect-ratio: 1; display: grid; place-items: center; padding: 0; min-width: 0; background: var(--surface-2); border: 0; border-radius: 10px; font-weight: 700; font-size: 14px; cursor: pointer; }
.day.blank { background: none; }
.day.on { background: var(--c); color: var(--surface); }
.day.today { box-shadow: inset 0 0 0 2px var(--ink); }
.day:disabled { opacity: .4; cursor: default; }

.week { display: grid; grid-template-columns: minmax(0, 1fr) repeat(7, 22px) 46px; gap: 9px 5px; align-items: center; }
.week-title { font-weight: 700; font-size: 14px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 20px; height: 20px; border-radius: 50%; background: var(--surface-2); justify-self: center; }
.dot.on { background: var(--c); }
.week-percent { font-size: 13px; text-align: right; }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 38px; height: 38px; padding: 0; background: var(--c); border: 3px solid transparent; border-radius: 50%; cursor: pointer; }
.swatch.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }

.page-head { display: grid; gap: 3px; }
.note { padding: 10px 14px; border-radius: var(--radius); background: var(--warn-soft); }
.auth { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
.auth-card { display: grid; gap: 14px; width: min(400px, 100%); padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.logo { display: flex; align-items: center; gap: 11px; font-size: 24px; font-weight: 800; }
