:root {
  --bg: #fafafa;
  --sidebar-bg: #f4f4f3;
  --border: #e6e6e4;
  --text: #202020;
  --text-muted: #7a7a78;
  --accent: #db4c3f;
  --p1: #d1453b;
  --p2: #eb8909;
  --p3: #246fe0;
  --p4: #b0b0ac;
  --hover: #efefee;
  --radius: 6px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
}

/* ---------- sidebar ---------- */

#sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  overflow-y: auto;
}

.sidebar-section { margin-bottom: 18px; }

.sidebar-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 4px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
}

.sidebar-item:hover { background: var(--hover); }
.sidebar-item.active { background: #fbe4e1; color: var(--accent); font-weight: 600; }

.sidebar-item .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--p4);
  flex-shrink: 0;
}

.sidebar-add {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
}
.sidebar-add:hover { color: var(--text); }

/* ---------- main ---------- */

#main {
  padding: 24px 32px;
  overflow-y: auto;
  max-width: 720px;
}

#view-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
}

#view-count {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 18px;
}

/* ---------- quick add ---------- */

#quick-add-bar {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px 12px;
  margin-bottom: 16px;
}

#quick-add-input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  background: transparent;
}

#quick-add-preview {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  min-height: 16px;
}
#quick-add-preview .new-tag { color: var(--accent); }

/* ---------- task list ---------- */

.task-list { list-style: none; margin: 0; padding: 0; }

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.task-row.focused { background: var(--hover); border-radius: var(--radius); }
.task-row.subtask { margin-left: 28px; }
.task-row.completed .task-title { text-decoration: line-through; color: var(--text-muted); }

.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  opacity: 0;
  padding-top: 2px;
  user-select: none;
}
.task-row:hover .drag-handle { opacity: 1; }

.task-checkbox {
  width: 16px; height: 16px;
  border: 1.5px solid var(--p4);
  border-radius: 50%;
  margin-top: 2px;
  cursor: pointer;
  flex-shrink: 0;
  background: #fff;
}
.task-checkbox.p1 { border-color: var(--p1); }
.task-checkbox.p2 { border-color: var(--p2); }
.task-checkbox.p3 { border-color: var(--p3); }
.task-checkbox:hover { background: var(--hover); }
.task-row.completed .task-checkbox { background: var(--p4); border-color: var(--p4); }

.task-body { flex: 1; min-width: 0; }

.task-title {
  outline: none;
  cursor: text;
  word-break: break-word;
}
.task-title:focus { background: #fff; box-shadow: 0 0 0 2px var(--accent) inset; border-radius: 3px; }

.task-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--hover);
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  font-family: inherit;
  font-size: 12px;
}
.chip:hover { background: #e4e4e2; }
.chip.due-today { color: var(--accent); background: #fbe4e1; }
.chip.due-overdue { color: #fff; background: var(--p1); }
.chip.due-future { color: var(--text-muted); }

.add-subtask-link {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  margin-top: 4px;
  display: inline-block;
}
.add-subtask-link:hover { color: var(--accent); }

.task-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  padding: 2px 4px;
}
.task-row:hover .task-delete { opacity: 1; }
.task-delete:hover { color: var(--p1); }

.subtask-input {
  margin-left: 28px;
  margin-bottom: 8px;
  width: calc(100% - 28px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-family: inherit;
  font-size: 13px;
}

.empty-state {
  color: var(--text-muted);
  padding: 24px 6px;
  font-size: 13.5px;
}

/* ---------- popovers ---------- */

.popover {
  position: fixed;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 8px;
  z-index: 1000;
  min-width: 200px;
}

.popover button.quick-option {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}
.popover button.quick-option:hover { background: var(--hover); }

.popover input[type="date"],
.popover input[type="time"],
.popover input[type="text"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 6px;
  font-family: inherit;
  font-size: 13px;
  margin-top: 6px;
}

.popover .popover-row { display: flex; gap: 6px; }
.popover hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }

.popover label.label-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  cursor: pointer;
  font-size: 13px;
}
.popover label.label-option:hover { background: var(--hover); border-radius: 4px; }

.priority-swatch {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block;
}
