:root {
  --bg: #0e0f13;
  --bg-soft: #16171d;
  --surface: #1e2028;
  --surface-2: #262a35;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eaf0;
  --text-dim: #9a9fb0;
  --accent: #00e5a0;
  --accent-2: #14b8ff;
  --danger: #ff5d6c;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

body.light {
  --bg: #eef1f7;
  --bg-soft: #e4e8f1;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --border: rgba(0, 0, 0, 0.08);
  --text: #1c1f2a;
  --text-dim: #6b7280;
  --shadow: 0 10px 30px rgba(30, 40, 80, 0.16);
}

/* ---------- Animated background blobs ---------- */
.bg-blobs {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.55;
}

.blob-1 {
  width: 420px;
  height: 420px;
  background: var(--accent);
  top: -120px;
  left: -100px;
  animation: drift 18s ease-in-out infinite;
}

.blob-2 {
  width: 380px;
  height: 380px;
  background: var(--accent-2);
  bottom: -140px;
  right: -100px;
  animation: drift 22s ease-in-out infinite reverse;
}

.blob-3 {
  width: 320px;
  height: 320px;
  background: #a855f7;
  top: 45%;
  left: 55%;
  opacity: 0.3;
  animation: drift 26s ease-in-out infinite;
}

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(40px, -30px) scale(1.1); }
  66%      { transform: translate(-30px, 30px) scale(0.95); }
}

/* ---------- Layout ---------- */
.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

/* ---------- Header ---------- */
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 26px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}

h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.icon-btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.icon-btn.danger:hover {
  border-color: var(--danger);
}

/* ---------- Stats ---------- */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  transition: transform 0.2s ease;
}

.stat:hover {
  transform: translateY(-2px);
}

.stat-num {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}

/* ---------- Progress ---------- */
.progress-wrap {
  height: 8px;
  background: var(--surface);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ---------- Input ---------- */
.input-section {
  margin: 24px 0 16px;
}

.input-row {
  display: flex;
  gap: 12px;
}

.task-input {
  flex: 1;
  padding: 15px 18px;
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.task-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 229, 160, 0.18);
}

.add-btn {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #07110c;
  font-size: 28px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.2s ease;
}

.add-btn:hover {
  transform: scale(1.05) rotate(90deg);
  filter: brightness(1.1);
}

.add-btn:active {
  transform: scale(0.95);
}

.input-options {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.select {
  flex: 1;
  padding: 10px 12px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.select:hover {
  border-color: var(--accent-2);
}

.select.small {
  flex: 0 0 auto;
  width: auto;
  min-width: 110px;
}

/* ---------- Filters ---------- */
.filters {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.filter-tabs {
  display: flex;
  gap: 6px;
  background: var(--surface);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.filter-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  color: var(--text-dim);
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.filter-btn.active {
  background: var(--accent);
  color: #07110c;
}

.filter-btn:not(.active):hover {
  color: var(--text);
}

.filter-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-input {
  padding: 9px 12px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  width: 130px;
  transition: border-color 0.2s ease, width 0.25s ease;
}

.search-input:focus {
  width: 180px;
  border-color: var(--accent-2);
}

/* ---------- Category filter ---------- */
.category-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.cat-btn {
  padding: 7px 13px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cat-btn.active {
  background: var(--accent);
  color: #07110c;
  border-color: var(--accent);
}

.cat-btn:not(.active):hover {
  border-color: var(--accent-2);
  color: var(--text);
}

/* ---------- Task list ---------- */
.task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  animation: slideIn 0.3s ease;
  transition: transform 0.2s ease, border-color 0.2s ease, opacity 0.3s ease;
}

.task-item:hover {
  transform: translateX(4px);
  border-color: var(--accent-2);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.task-item.removing {
  animation: slideOut 0.25s ease forwards;
}

@keyframes slideOut {
  to { opacity: 0; transform: translateX(60px) scale(0.95); }
}

.task-item.completed {
  opacity: 0.55;
}

.task-item.completed .task-title {
  text-decoration: line-through;
  color: var(--text-dim);
}

.task-check {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  margin-top: 2px;
  border: 2px solid var(--text-dim);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  color: transparent;
  transition: all 0.2s ease;
}

.task-item.completed .task-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #07110c;
}

.task-check:hover {
  border-color: var(--accent);
  transform: scale(1.1);
}

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

.task-title {
  font-size: 15px;
  font-weight: 600;
  word-break: break-word;
}

.task-note {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  word-break: break-word;
}

.task-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  border: 1px solid transparent;
}

.tag.priority-high {
  background: rgba(255, 93, 108, 0.15);
  color: var(--danger);
  border-color: rgba(255, 93, 108, 0.4);
}

.tag.priority-medium {
  background: rgba(255, 190, 11, 0.12);
  color: #fbbf24;
  border-color: rgba(255, 190, 11, 0.4);
}

body.light .tag.priority-medium { color: #b45309; }

.tag.priority-low {
  background: rgba(0, 229, 160, 0.12);
  color: var(--accent);
  border-color: rgba(0, 229, 160, 0.4);
}

body.light .tag.priority-low { color: #047857; }

.tag.due {
  background: var(--surface-2);
  color: var(--accent-2);
  border-color: rgba(20, 184, 255, 0.4);
}

.tag.due.overdue {
  background: rgba(255, 93, 108, 0.15);
  color: var(--danger);
  border-color: rgba(255, 93, 108, 0.4);
}

.tag.due.today {
  background: rgba(255, 190, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(255, 190, 11, 0.4);
}

body.light .tag.due.today { color: #b45309; }

.task-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.task-action-btn {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}

.task-action-btn:hover {
  transform: scale(1.12);
}

.task-action-btn.edit:hover { background: rgba(20, 184, 255, 0.2); }
.task-action-btn.del:hover { background: rgba(255, 93, 108, 0.2); }

.empty-state {
  background: var(--bg-soft);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}

.empty-icon {
  font-size: 40px;
  display: block;
  margin-bottom: 10px;
}

/* ---------- Bulk actions ---------- */
.bulk-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: center;
}

.bulk-btn {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bulk-btn:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  animation: popIn 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@keyframes popIn {
  from { transform: scale(0.9) translateY(10px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal h2 {
  font-size: 20px;
}

.note-input {
  resize: vertical;
  min-height: 70px;
  padding: 12px 14px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}

.note-input:focus {
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-actions .add-btn {
  width: auto;
  height: auto;
  padding: 12px 22px;
  font-size: 15px;
  border-radius: 10px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 22px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 100;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ---------- Recommit animation ---------- */
.task-item.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

@media (max-width: 480px) {
  .app { padding: 20px 14px 40px; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .search-input { width: 110px; }
  .filters { flex-direction: column; align-items: stretch; }
  .filter-right { justify-content: space-between; }
}