:root {
  --accent: #4f46e5;
  --accent-light: #eef2ff;
  --sidebar-w: 252px;
  --text: #1c1917;
  --text-secondary: #78716c;
  --text-muted: #a8a29e;
  --border: #e7e5e4;
  --bg: #fff;
  --bg-sidebar: #fafaf9;
  --bg-hover: #f5f5f4;
  --completed-text: #a8a29e;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --radius: 6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── App shell ── */
.app {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.app-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -.3px;
}

.sidebar-lists {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 12px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: var(--radius);
  margin: 1px 8px;
  cursor: pointer;
  transition: background .1s;
  user-select: none;
}
.list-item:hover { background: var(--bg-hover); }
.list-item.active { background: var(--accent-light); }
.list-item.active .list-item-name { color: var(--accent); font-weight: 600; }
.list-item.active .list-item-icon { color: var(--accent); }

.list-item-icon { font-size: 9px; color: var(--text-muted); flex-shrink: 0; }
.list-item-name { flex: 1; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item-count { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }

.sidebar-footer {
  padding: 10px 8px;
  border-top: 1px solid var(--border);
}

.new-list-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: background .1s, color .1s;
}
.new-list-btn:hover { background: var(--bg-hover); color: var(--text); }
.new-list-btn-plus { font-size: 16px; font-weight: 300; line-height: 1; }

.new-list-wrap {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
}
.new-list-input {
  flex: 1;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
  background: var(--bg);
}

/* ── Main ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 48px 48px;
  max-width: 680px;
}

.main-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 20px;
}

.main-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.3px;
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
  transition: background .1s;
  flex: 1;
}
.main-title:hover { background: var(--bg-hover); }

.title-edit-input {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.3px;
  border: none;
  border-bottom: 2px solid var(--accent);
  outline: none;
  background: transparent;
  width: 100%;
  padding: 2px 0;
}

.list-delete-btn {
  font-size: 12px;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color .1s, border-color .1s;
}
.list-delete-btn:hover { color: var(--danger); border-color: var(--danger); }

/* ── Task items ── */
.task-list { display: flex; flex-direction: column; gap: 2px; }

.all-list-section { margin-bottom: 24px; }
.all-list-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  padding: 0 4px;
  margin-bottom: 6px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
  border-radius: var(--radius);
  transition: background .1s;
  group: true;
}
.task-item:hover { background: var(--bg-hover); }
.task-item:hover .item-delete { opacity: 1; }

.item-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, background .15s;
  padding: 0;
}
.item-check:hover { border-color: var(--accent); }
.item-check.checked { background: var(--accent); border-color: var(--accent); }

.item-text {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  cursor: text;
  line-height: 1.4;
  word-break: break-word;
}
.task-item.completed .item-text {
  color: var(--completed-text);
  text-decoration: line-through;
}

.item-edit-input {
  flex: 1;
  border: none;
  border-bottom: 1px solid var(--accent);
  outline: none;
  font-size: 14px;
  color: var(--text);
  background: transparent;
  padding: 0;
}

.item-delete {
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color .1s, background .1s, opacity .1s;
  padding: 0;
}
.item-delete:hover { color: var(--danger); background: #fef2f2; }

/* ── Add item ── */
.add-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
  margin-top: 4px;
  border-radius: var(--radius);
  transition: background .1s;
}
.add-item-row:focus-within { background: var(--bg-hover); }

.add-item-plus {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--accent);
  font-weight: 300;
  flex-shrink: 0;
}

.add-item-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text);
  background: transparent;
}
.add-item-input::placeholder { color: var(--text-muted); }

/* ── Completed section ── */
.completed-section { margin-top: 12px; }

.completed-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius);
  transition: color .1s;
}
.completed-toggle:hover { color: var(--text); }
.completed-toggle-arrow { font-size: 10px; width: 10px; }
.completed-count { color: var(--text-muted); }

.completed-items { margin-top: 4px; }
.completed-items.hidden { display: none; }

/* ── Empty ── */
.empty-note { color: var(--text-muted); font-size: 14px; padding: 8px 4px; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .sidebar { width: 200px; }
  .main-content { padding: 20px 20px 40px; }
}
