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

:root {
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-hover: rgba(255, 255, 255, 0.08);
  --text-primary: #f1f1f1;
  --text-secondary: rgba(255, 255, 255, 0.5);
  --text-muted: rgba(255, 255, 255, 0.25);
  --accent: #a78bfa;
  --accent-glow: rgba(167, 139, 250, 0.15);
  --green: #6ee7b7;
  --green-glow: rgba(110, 231, 183, 0.15);
  --red: #fb7185;
  --blue: #60a5fa;
  --orange: #fbbf24;
  --low-color: #6ee7b7;
  --medium-color: #fbbf24;
  --high-color: #fb923c;
  --urgent-color: #fb7185;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow: 0 25px 60px -20px rgba(0, 0, 0, 0.6);
  --transition: 0.25s ease;
}

body {
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem 1rem;
  color: var(--text-primary);
  background: linear-gradient(135deg, #0f0c29 0%, #302b63 40%, #24243e 100%);
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(167, 139, 250, 0.12), transparent 70%);
  top: -200px;
  right: -100px;
  z-index: 0;
  pointer-events: none;
}

body::after {
  content: '';
  position: fixed;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(96, 165, 250, 0.1), transparent 70%);
  bottom: -250px;
  left: -150px;
  z-index: 0;
  pointer-events: none;
}

.container {
  width: 100%;
  max-width: 600px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 24px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--glass-border);
  position: relative;
  z-index: 1;
}

header {
  text-align: center;
  margin-bottom: 1.5rem;
}

header h1 {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.5px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.2rem;
  font-weight: 400;
}

.stats-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.stat {
  text-align: center;
  min-width: 48px;
}

.stat-num {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-muted);
}

.progress-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: auto;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  overflow: hidden;
}

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

.progress-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: center;
}

.search-box {
  margin-bottom: 1rem;
}

.search-box input {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 400;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-box input:focus {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
}

.input-section {
  margin-bottom: 1rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius);
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.input-row + .input-row {
  margin-top: 0.5rem;
}

.input-row input[type="text"] {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.input-row input[type="text"]::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.input-row input[type="text"]:focus {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.07);
}

.priority-select {
  display: flex;
  gap: 0.25rem;
}

.p-btn {
  padding: 0.5rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1;
}

.p-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.p-btn.active {
  border-color: rgba(255, 255, 255, 0.15);
}

.p-btn.p-low.active { color: var(--low-color); border-color: rgba(110, 231, 183, 0.3); background: rgba(110, 231, 183, 0.08); }
.p-btn.p-medium.active { color: var(--medium-color); border-color: rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.08); }
.p-btn.p-high.active { color: var(--high-color); border-color: rgba(251, 146, 60, 0.3); background: rgba(251, 146, 60, 0.08); }
.p-btn.p-urgent.active { color: var(--urgent-color); border-color: rgba(251, 113, 133, 0.3); background: rgba(251, 113, 133, 0.08); }

.secondary {
  flex-wrap: wrap;
}

.date-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.date-label {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
}

.date-wrap input[type="date"] {
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 400;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
  color-scheme: dark;
}

.date-wrap input[type="date"]:focus {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.07);
}

.date-wrap input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.6);
  cursor: pointer;
}

.category-wrap select {
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 400;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
  padding-left: 1.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='rgba(255,255,255,0.4)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.5rem center;
}

.category-wrap select:focus {
  border-color: rgba(255, 255, 255, 0.15);
  background-color: rgba(255, 255, 255, 0.07);
}

.category-wrap select option {
  background: #1e1b3a;
  color: #fff;
}

.add-btn {
  padding: 0.65rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  margin-right: auto;
}

.add-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(102, 126, 234, 0.35);
}

.add-btn:active {
  transform: translateY(0);
}

.controls-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.sort-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.sort-wrap label {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
}

.sort-wrap select {
  padding: 0.45rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 400;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
  padding-left: 1.3rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='rgba(255,255,255,0.4)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.4rem center;
}

.sort-wrap select:focus {
  border-color: rgba(255, 255, 255, 0.15);
  background-color: rgba(255, 255, 255, 0.07);
}

.sort-wrap select option {
  background: #1e1b3a;
  color: #fff;
}

.filters {
  display: flex;
  gap: 0.3rem;
  margin: 0 auto;
}

.filter {
  padding: 0.45rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

.filter:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
}

.filter.active {
  color: var(--accent);
  border-color: rgba(167, 139, 250, 0.25);
  background: rgba(167, 139, 250, 0.08);
}

.clear-btn {
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(251, 113, 133, 0.12);
  border-radius: 8px;
  background: rgba(251, 113, 133, 0.06);
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.clear-btn:hover {
  background: rgba(251, 113, 133, 0.15);
  border-color: rgba(251, 113, 133, 0.25);
}

.clear-btn:disabled {
  opacity: 0.3;
  cursor: default;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

#taskList {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 60px;
}

.task-item {
  background: var(--glass-bg);
  border-radius: var(--radius);
  padding: 0.8rem 0.9rem 0.8rem 0.5rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  transition: var(--transition);
  border: 1px solid var(--glass-border);
  animation: slideIn 0.3s ease;
  position: relative;
  cursor: default;
}

.task-item.dragging {
  opacity: 0.4;
  transform: scale(0.97);
}

.task-item.drag-over {
  border-color: var(--accent);
  background: rgba(167, 139, 250, 0.06);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.task-item:hover {
  background: var(--glass-hover);
  border-color: rgba(255, 255, 255, 0.1);
}

.drag-handle {
  width: 20px;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-top: 0.1rem;
  user-select: none;
  transition: var(--transition);
  opacity: 0;
}

.task-item:hover .drag-handle {
  opacity: 1;
}

.drag-handle:active {
  cursor: grabbing;
}

.task-check {
  width: 20px;
  height: 20px;
  min-width: 20px;
  margin-top: 0.15rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.task-check:hover {
  border-color: var(--green);
}

.task-check.checked {
  background: var(--green);
  border-color: var(--green);
}

.task-check.checked::after {
  content: '✓';
  color: #0f0c29;
  font-size: 12px;
  font-weight: 800;
}

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

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

.task-pin {
  font-size: 0.7rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  background: none;
  border: none;
  font-family: inherit;
  line-height: 1;
  padding: 0;
}

.task-pin:hover {
  color: var(--medium-color);
}

.task-pin.pinned {
  color: var(--medium-color);
}

.task-text {
  font-size: 0.9rem;
  font-weight: 500;
  word-break: break-word;
  line-height: 1.6;
  transition: var(--transition);
}

.task-text.done {
  text-decoration: line-through;
  color: var(--text-muted);
  font-weight: 400;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.2rem;
}

.task-date {
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--text-muted);
}

.priority-badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 5px;
  line-height: 1.4;
}

.priority-badge.low { background: rgba(110, 231, 183, 0.1); color: var(--low-color); }
.priority-badge.medium { background: rgba(251, 191, 36, 0.1); color: var(--medium-color); }
.priority-badge.high { background: rgba(251, 146, 60, 0.1); color: var(--high-color); }
.priority-badge.urgent { background: rgba(251, 113, 133, 0.1); color: var(--urgent-color); }

.category-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.category-dot.personal { background: #a78bfa; }
.category-dot.work { background: #60a5fa; }
.category-dot.study { background: #6ee7b7; }
.category-dot.health { background: #fb7185; }
.category-dot.finance { background: #fbbf24; }
.category-dot.other { background: rgba(255, 255, 255, 0.3); }

.category-label {
  font-size: 0.6rem;
  font-weight: 400;
  color: var(--text-muted);
}

.due-badge {
  font-size: 0.6rem;
  font-weight: 500;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.due-badge.overdue {
  color: var(--red);
  border-color: rgba(251, 113, 133, 0.2);
  background: rgba(251, 113, 133, 0.06);
}

.due-badge.today {
  color: var(--medium-color);
  border-color: rgba(251, 191, 36, 0.2);
  background: rgba(251, 191, 36, 0.06);
}

.task-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.task-item:hover .task-actions {
  opacity: 1;
}

.task-actions button {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-edit {
  background: rgba(167, 139, 250, 0.1);
  color: var(--accent);
}

.btn-edit:hover {
  background: rgba(167, 139, 250, 0.25);
  color: #c4b5fd;
}

.btn-delete {
  background: rgba(251, 113, 133, 0.1);
  color: var(--red);
}

.btn-delete:hover {
  background: rgba(251, 113, 133, 0.25);
  color: #fda4af;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
}

.empty-state p {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-muted);
}

.footer-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.footer-btn {
  padding: 0.5rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 400;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

.footer-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border-color: rgba(255, 255, 255, 0.1);
}

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 50%;
  transform: translateX(50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: rgba(30, 27, 58, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.2rem;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: inherit;
  box-shadow: 0 12px 40px -12px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toast .toast-undo {
  padding: 0.3rem 0.7rem;
  border: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: 6px;
  background: rgba(167, 139, 250, 0.1);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

.toast .toast-undo:hover {
  background: rgba(167, 139, 250, 0.2);
}

@keyframes toastIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

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

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  justify-content: center;
  align-items: center;
  z-index: 5000;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.show {
  display: flex;
}

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

.modal {
  background: rgba(30, 27, 58, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: scaleIn 0.25s ease;
}

@keyframes scaleIn {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal h3 {
  margin-bottom: 1.25rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.modal input {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
  margin-bottom: 1.25rem;
}

.modal input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.modal input:focus {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.07);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.modal-actions button {
  padding: 0.65rem 1.4rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

.btn-cancel {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
}

.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.btn-save {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
}

.btn-save:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(102, 126, 234, 0.35);
}

#confettiCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9998;
}

@media (max-width: 540px) {
  body { padding: 0.75rem; }
  .container { padding: 1.25rem; border-radius: 18px; }
  header h1 { font-size: 1.5rem; }
  .stats-bar { flex-wrap: wrap; gap: 0.5rem; }
  .stat { min-width: 36px; }
  .stat-num { font-size: 0.95rem; }
  .progress-wrap { width: 100%; order: 10; }
  .input-row { flex-wrap: wrap; }
  .priority-select { width: 100%; justify-content: center; }
  .secondary .date-wrap,
  .secondary .category-wrap { flex: 1; }
  .secondary .category-wrap select { width: 100%; }
  .add-btn { width: 100%; margin-top: 0.25rem; }
  .controls-bar { flex-direction: column; align-items: stretch; }
  .sort-wrap { justify-content: center; }
  .filters { margin: 0; justify-content: center; }
  .clear-btn { width: 100%; text-align: center; }
  .drag-handle { display: none; }
  .task-actions { opacity: 1; }
  .task-actions button { width: 28px; height: 28px; font-size: 0.75rem; }
}
