:root {
  --sidebar-bg: #1e1a2e;
  --sidebar-fg: #c9c3e0;
  --sidebar-fg-active: #ffffff;
  --accent: #7c5cff;
  --accent-soft: #efe9ff;
  --bg: #f7f7fb;
  --card-bg: #ffffff;
  --border: #e5e3ef;
  --text: #23212e;
  --text-muted: #6f6c85;
  --danger: #e5484d;
  --warn: #f5a623;
  --ok: #2fb380;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 16, 50, 0.04), 0 1px 8px rgba(20, 16, 50, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, textarea, select {
  font-family: inherit;
  font-size: 14px;
}

/* ---------- Auth screen ---------- */

#auth-section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  width: 320px;
}

.auth-card h1 {
  font-size: 1.25rem;
  margin: 0 0 1.25rem;
}

.auth-card input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.auth-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-weight: 600;
  font-size: 13px;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #6a49f2; }
.btn-secondary { background: var(--accent-soft); color: var(--accent); }
.btn-secondary:hover { background: #e2d9ff; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: #eeecf7; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 12px; border-radius: 6px; }

.error-text { color: var(--danger); font-size: 12.5px; margin-top: 0.4rem; min-height: 1em; }

/* ---------- App shell ---------- */

#app { display: flex; min-height: 100vh; }
.hidden { display: none !important; }

#sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  padding: 1.1rem 0.9rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: #fff;
  font-size: 15px;
  padding: 0.3rem 0.4rem 1.2rem;
}

.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.6rem;
  border-radius: 8px;
  color: var(--sidebar-fg);
  cursor: pointer;
  font-weight: 500;
  margin-bottom: 0.15rem;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-size: 13.5px;
}

.nav-item svg { opacity: 0.85; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: var(--sidebar-fg-active); }
.nav-item.active { background: rgba(124, 92, 255, 0.28); color: #fff; }

.sidebar-section-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8e88ab;
  margin: 1.1rem 0 0.4rem 0.6rem;
}

.category-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0 0.4rem;
}

#sidebar-spacer { flex: 1; }

.score-widget {
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 0.9rem;
  margin-top: 0.6rem;
}

.score-widget .label { font-size: 11px; color: #a49fc4; text-transform: uppercase; letter-spacing: 0.05em; }
.score-widget .value { font-size: 1.7rem; font-weight: 700; color: #fff; line-height: 1.3; }
.score-widget .sub { font-size: 11.5px; color: #a49fc4; margin-top: 0.15rem; }

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.9rem;
  padding: 0 0.4rem;
}

.user-email { font-size: 12px; color: #a49fc4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }

/* ---------- Main area ---------- */

#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#topbar {
  padding: 1rem 1.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}

.view-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.7rem;
}

.quick-add {
  display: flex;
  gap: 0.5rem;
}

.quick-add input {
  flex: 1;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.quick-add input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

#clarify-banner {
  margin-top: 0.6rem;
  background: #fff6e5;
  border: 1px solid #ffe1a8;
  color: #8a5b00;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 13px;
}

#content {
  flex: 1;
  overflow-y: auto;
  padding: 1.4rem 1.6rem 3rem;
}

/* ---------- Badges / pills ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 100px;
  white-space: nowrap;
  background: #eef1f5;
  color: #667085;
}

.pill-origin { background: #eef0ff; color: #4b53c9; }

.pill-importance-max { background: #fde8e8; color: #c2333a; }
.pill-importance-medium { background: #fff3e0; color: #b06d00; }
.pill-importance-low { background: #eef1f5; color: #667085; }

.pill-urgency-very_urgent, .pill-urgency-strict_deadline { background: #fde8e8; color: #c2333a; }
.pill-urgency-needs_doing { background: #fff3e0; color: #b06d00; }
.pill-urgency-not_urgent { background: #eaf7f0; color: #1f8a56; }

.pill-status-pending { background: #eef1f5; color: #667085; }
.pill-status-scheduled { background: #eef0ff; color: #4b53c9; }
.pill-status-in_progress { background: #fff3e0; color: #b06d00; }
.pill-status-completed { background: #eaf7f0; color: #1f8a56; }
.pill-status-cancelled { background: #f5f5f5; color: #9a9a9a; }

.pill-new { background: #f3e8ff; color: #8b3fd1; }

/* ---------- List view ---------- */

.group-heading {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 1.4rem 0 0.5rem;
}
.group-heading:first-child { margin-top: 0; }

.task-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
}

.task-card.completed { opacity: 0.55; }
.task-card.completed .task-title { text-decoration: line-through; }

.check-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: none;
  flex-shrink: 0;
  margin-top: 1px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.check-btn.checked { background: var(--ok); border-color: var(--ok); color: white; }
.check-btn:hover { border-color: var(--ok); }

.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 13.5px; }
.task-desc { color: var(--text-muted); font-size: 12.5px; margin: 0.15rem 0 0.4rem; }

.task-meta-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.task-meta-text { font-size: 11.5px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 0.25rem; }

.task-actions { display: flex; gap: 0.3rem; align-items: center; flex-shrink: 0; }
.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.3rem;
  border-radius: 6px;
  display: flex;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }

.empty-state { color: var(--text-muted); font-size: 13px; padding: 2rem 0; text-align: center; }

/* ---------- Board view ---------- */

.board {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 1rem;
}

.board-column {
  background: #eeecf5;
  border-radius: var(--radius);
  width: 280px;
  flex-shrink: 0;
  padding: 0.7rem;
  min-height: 120px;
}

.board-column.drag-over { background: var(--accent-soft); outline: 2px dashed var(--accent); }

.board-column-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  display: flex;
  justify-content: space-between;
}

.board-card {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0.65rem 0.7rem;
  margin-bottom: 0.5rem;
  cursor: grab;
}
.board-card:active { cursor: grabbing; }
.board-card .task-title { font-size: 13px; }
.board-card .task-meta-row { margin-top: 0.4rem; }

/* ---------- Calendar view ---------- */

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

.calendar-header .month-label { font-weight: 700; font-size: 1rem; }
.calendar-nav { display: flex; gap: 0.35rem; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-dow {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  text-align: center;
  padding-bottom: 0.3rem;
}

.calendar-cell {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 92px;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.calendar-cell.other-month { background: #fbfaff; opacity: 0.55; }
.calendar-cell.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

.calendar-date { font-size: 11.5px; font-weight: 600; color: var(--text-muted); }
.calendar-cell.today .calendar-date { color: var(--accent); }

.cal-chip {
  font-size: 10.5px;
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  border-left: 2px solid var(--accent);
}
.cal-chip.deadline-only { border-left-style: dashed; background: #fff3e0; color: #b06d00; border-left-color: #b06d00; }
.cal-chip.completed { text-decoration: line-through; opacity: 0.6; }

.cal-more { font-size: 10px; color: var(--text-muted); padding-left: 0.35rem; }

/* ---------- Schedule popover ---------- */

.popover-backdrop {
  position: fixed; inset: 0; background: rgba(20,16,50,0.25);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}

.popover {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.1rem;
  width: 300px;
  box-shadow: 0 8px 30px rgba(20,16,50,0.2);
}

.popover h3 { margin: 0 0 0.8rem; font-size: 14px; }
.popover label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 0.2rem; }
.popover input { width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 0.7rem; }
.popover-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.3rem; }

/* ---------- Toast ---------- */

#toast {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  background: #23212e;
  color: white;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  font-size: 12.5px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  z-index: 60;
}
#toast.error { background: var(--danger); }
