:root {
  --bg: #f6f5f1; --card: #ffffff; --ink: #1c1d20; --muted: #5f6368; --line: #e3e1da;
  --accent: #1f8a5b; --accent-ink: #ffffff; --soft: #e2f3ea; --danger: #b3261e;
  --radius: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16171a; --card: #202227; --ink: #eceef0; --muted: #a2a7ae; --line: #33363d;
    --accent: #3fbf86; --accent-ink: #0d2419; --soft: #1d3a2c; --danger: #f2817a; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 1rem; line-height: 1.4; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 560px; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom)); }
.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 8px 0 16px; }
h1 { font-size: 1.75rem; margin: 0; letter-spacing: -0.02em; }
.date { margin: 0; color: var(--muted); }

.add { display: flex; gap: 8px; margin-bottom: 20px; }
.add input, .rename input { flex: 1; min-width: 0; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.add button, .rename button { min-height: 48px; padding: 0 18px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.empty { text-align: center; background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 32px 20px; }
.empty h2 { margin: 12px 0 6px; font-size: 1.25rem; }
.empty p { margin: 0 auto 18px; color: var(--muted); max-width: 34ch; }
.empty-dots { display: flex; justify-content: center; gap: 8px; }
.empty-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); }
.empty-dots i.on { background: var(--accent); border-color: var(--accent); }
.ideas { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ideas button { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.habit { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.tick { flex: none; width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--line); background: transparent; display: grid; place-items: center; transition: background .15s, border-color .15s; }
.tick svg { width: 26px; height: 26px; fill: none; stroke: var(--line); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.done .tick { background: var(--accent); border-color: var(--accent); }
.done .tick svg { stroke: var(--accent-ink); }
.info { flex: 1; min-width: 0; }
.name { margin: 0; font-size: 1.0625rem; font-weight: 600; overflow-wrap: anywhere; }
.streaks { margin: 2px 0 0; color: var(--muted); font-size: .9375rem; }
.more { flex: none; width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 1.4rem; line-height: 1; }
.more[aria-expanded="true"] { background: var(--bg); }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 12px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 48px; padding: 4px 0; border: 0; border-radius: 10px; background: transparent; }
.day:hover { background: var(--bg); }
.dl { font-size: .75rem; color: var(--muted); }
.is-today .dl { color: var(--ink); font-weight: 700; }
.dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); }
.day.on .dot { background: var(--accent); border-color: var(--accent); }

.edit { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.edit[hidden], .empty[hidden] { display: none; }
.rename { display: flex; gap: 8px; }
.cur { color: var(--ink); font-weight: 600; }
.cur, .best { white-space: nowrap; }
.delete { justify-self: start; min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--danger); font-weight: 600; }

.foot { text-align: center; color: var(--muted); font-size: .875rem; margin-top: 24px; }
@media (min-width: 640px) { .wrap { padding-top: 48px; } h1 { font-size: 2rem; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
