:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e4e6ea;
  --text: #1b1d21;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 18, 24, .06), 0 8px 24px rgba(16, 18, 24, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --border: #262a32;
    --text: #e8eaed;
    --muted: #9aa1ad;
    --accent: #8b85ff;
    --accent-soft: #21203a;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 32px 16px 64px;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 620px; margin: 0 auto; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }

.account { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.account-label { color: var(--muted); font-size: 13px; }

.btn {
  font: inherit;
  font-size: 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  padding: 8px 14px;
  cursor: pointer;
}

.btn-primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface); }

.linkbtn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sync-note {
  margin: 0 0 16px;
  padding: 10px 14px;
  background: var(--accent-soft);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
}

.new-form { display: flex; gap: 10px; margin-bottom: 16px; }

.new-input {
  flex: 1;
  font: inherit;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.new-input:focus,
.edit-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.filters { display: flex; gap: 8px; margin-bottom: 14px; }

.chip {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.chip.is-active { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.count { opacity: .7; margin-left: 2px; font-variant-numeric: tabular-nums; }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.list:empty { display: none; }

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.item:last-child { border-bottom: 0; }

.item input[type="checkbox"] {
  width: 19px;
  height: 19px;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}

.title {
  flex: 1;
  cursor: text;
  word-break: break-word;
}

.item.done .title { color: var(--muted); text-decoration: line-through; }

.edit-input {
  flex: 1;
  font: inherit;
  padding: 4px 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.del {
  flex: none;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.del:hover { color: var(--danger); background: var(--bg); }

.empty { text-align: center; color: var(--muted); padding: 32px 8px; margin: 0; }

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 24px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}

.credit { margin-top: 40px; text-align: center; font-size: 12px; color: var(--muted); }
.credit a { color: var(--muted); }
