:root {
  color-scheme: light dark;
  --bg: #f6f4ef; --card: #ffffff; --text: #1f2420; --muted: #6b716c; --line: #e3e0d8;
  --accent: #2f6f5e; --accent-soft: #dcebe5; --late: #b3412e; --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151816; --card: #1f2321; --text: #e9ece9; --muted: #9aa29c; --line: #303632; --accent: #6cc1a6; --accent-soft: #24392f; --late: #ef8a74; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.4; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.top {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 12px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.top p { margin: 2px 0 0; font-size: 0.9rem; }
.filter { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.filter button { border: 0; background: none; border-radius: 999px; padding: 6px 14px; cursor: pointer; min-height: 36px; }
.filter button[aria-pressed="true"] { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .filter button[aria-pressed="true"] { color: #10201a; } }

main { max-width: 640px; margin: 0 auto; padding: 8px 14px calc(env(safe-area-inset-bottom) + 110px); }
.message { background: #fdecea; color: #7a2418; border-radius: 10px; padding: 10px 12px; }
.empty { text-align: center; color: var(--muted); padding: 28px 0 8px; }
.group { margin-top: 18px; }
.group h2 { display: flex; align-items: center; gap: 8px; margin: 0 4px 8px; }
.count { background: var(--line); color: var(--text); border-radius: 999px; padding: 0 8px; font-size: 0.75rem; letter-spacing: 0; }
ul { list-style: none; margin: 0; padding: 0; }

.task { display: flex; align-items: center; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; padding-left: 10px; }
.check {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--accent); background: none;
  display: grid; place-items: center; cursor: pointer; color: #fff; font-weight: 700;
}
.check:hover { background: var(--accent-soft); }
.task.done .check { background: var(--accent); }
.body { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 12px 12px 12px 6px; cursor: pointer; display: grid; gap: 3px; }
.title { font-weight: 600; overflow-wrap: anywhere; }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 0.85rem; color: var(--muted); }
.tag { background: var(--line); color: var(--text); border-radius: 6px; padding: 0 6px; }
.tag.mine { background: var(--accent-soft); }
.late { color: var(--late); font-weight: 600; }

[hidden] { display: none !important; }
.login { margin: 48px auto 0; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px; display: grid; gap: 14px; }
.login h2 { font-size: 1.25rem; text-transform: none; letter-spacing: 0; color: var(--text); }
.login p { margin: 0; }
.primary { min-height: 48px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; padding: 10px 18px; }
@media (prefers-color-scheme: dark) { .primary { color: #10201a; } }
.small { font-size: 0.85rem; }
.account { text-align: center; margin-top: 28px; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; min-height: 44px; }
.history { margin-top: 28px; }
.history h2 { margin: 0 4px 8px; }
.history li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: 0.9rem; }

.add {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 18px);
  border: 0; border-radius: 999px; padding: 14px 24px; background: var(--accent); color: #fff; font-weight: 600;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.2); cursor: pointer;
}
@media (prefers-color-scheme: dark) { .add { color: #10201a; } }

dialog { border: 0; border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 24px)); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / 0.4); }
form { display: grid; gap: 14px; padding: 20px; }
form h2 { font-size: 1.15rem; text-transform: none; letter-spacing: 0; color: var(--text); }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; font-weight: 600; font-size: 0.9rem; }
.field legend { padding: 0; margin-bottom: 6px; }
input[type="date"], input:not([type]), select { width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-weight: 400; }
.chips, .due-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.due-row input { flex: 1 1 100%; width: auto; }
@media (min-width: 560px) { .due-row input { flex-basis: 160px; } }
@media (max-height: 500px) {
  form { gap: 8px; padding: 14px 18px; }
  .hint { display: none; }
}
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); font-weight: 400; cursor: pointer; }
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.chip input { accent-color: var(--accent); margin: 0; }
.hint { margin: -6px 0 0; font-size: 0.85rem; }
.actions { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }
.actions button { min-height: 44px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; }
.actions .primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .actions .primary { color: #10201a; } }
.actions .danger { color: var(--late); }
