/* Material Design 3 Color System */
:root[data-theme="light"] {
  --primary: #6750A4;
  --on-primary: #FFFFFF;
  --primary-container: #EADDFF;
  --on-primary-container: #21005D;
  --secondary: #625B71;
  --on-secondary: #FFFFFF;
  --secondary-container: #E8DEF8;
  --on-secondary-container: #1D192B;
  --tertiary: #7D5260;
  --on-tertiary: #FFFFFF;
  --tertiary-container: #FFD8E4;
  --on-tertiary-container: #31111D;
  --error: #B3261E;
  --on-error: #FFFFFF;
  --error-container: #F9DEDC;
  --on-error-container: #410E0B;
  --background: #FEF7FF;
  --on-background: #1D1B20;
  --surface: #FEF7FF;
  --surface-variant: #E7E0EC;
  --on-surface: #1D1B20;
  --on-surface-variant: #49454F;
  --outline: #79747E;
  --shadow: rgba(0, 0, 0, 0.15);
}

:root[data-theme="dark"] {
  --primary: #D0BCFF;
  --on-primary: #381E72;
  --primary-container: #4F378B;
  --on-primary-container: #EADDFF;
  --secondary: #CCC2DC;
  --on-secondary: #332D41;
  --secondary-container: #4A4458;
  --on-secondary-container: #E8DEF8;
  --tertiary: #EFB8C8;
  --on-tertiary: #492532;
  --tertiary-container: #633B48;
  --on-tertiary-container: #FFD8E4;
  --error: #F2B8B5;
  --on-error: #601410;
  --error-container: #8C1D18;
  --on-error-container: #F9DEDC;
  --background: #141218;
  --on-background: #E6E0E9;
  --surface: #141218;
  --surface-variant: #49454F;
  --on-surface: #E6E0E9;
  --on-surface-variant: #CAC4D0;
  --outline: #938F99;
  --shadow: rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--background);
  color: var(--on-background);
  transition: background 0.5s cubic-bezier(0.4, 0, 0.2, 1), color 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 100vh;
  overflow-x: hidden;
  perspective: 1000px;
}

.app-container {
  max-width: min(680px, 100%);
  margin: 0 auto;
  padding: 0 clamp(12px, 4vw, 20px);
  width: 100%;
}

.app-header {
  padding: clamp(16px, 5vw, 32px) 0 clamp(12px, 4vw, 24px);
  position: sticky;
  top: 0;
  background: var(--background);
  z-index: 100;
  transition: background 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 12px);
}

.logo-icon {
  font-size: clamp(28px, 6vw, 36px);
  color: var(--primary);
  animation: pulse 2s ease-in-out infinite;
}

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

h1 {
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary) 0%, var(--tertiary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.theme-toggle {
  width: clamp(40px, 10vw, 48px);
  height: clamp(40px, 10vw, 48px);
  border-radius: 50%;
  border: none;
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 8px var(--shadow), 0 2px 4px rgba(0,0,0,0.1);
  position: relative;
  overflow: hidden;
  transform: translateZ(0);
  flex-shrink: 0;
}

.theme-toggle::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--primary);
  opacity: 0;
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 24px;
}

.theme-toggle:hover::before {
  opacity: 0.1;
}

.theme-toggle:hover {
  transform: scale(1.08) rotate(180deg) translateZ(10px);
  box-shadow: 0 8px 20px var(--shadow), 0 4px 8px rgba(0,0,0,0.15);
}

.theme-toggle .material-symbols-rounded {
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 1;
}

.theme-toggle:active .material-symbols-rounded {
  transform: rotate(360deg);
}

.input-card {
  background: var(--surface);
  border-radius: clamp(16px, 4vw, 28px);
  padding: clamp(6px, 1.5vw, 8px);
  box-shadow: 0 8px 24px var(--shadow), 0 4px 12px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.1);
  margin-bottom: clamp(16px, 4vw, 24px);
  border: 1px solid var(--outline);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateZ(0);
  transform-style: preserve-3d;
}

.input-card:focus-within {
  box-shadow: 0 12px 32px var(--shadow), 0 6px 16px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.2);
  border-color: var(--primary);
  transform: translateY(-4px) translateZ(20px);
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 12px);
  padding: clamp(2px, 1vw, 4px) clamp(4px, 1.5vw, 8px);
}

.input-icon {
  color: var(--primary);
  font-size: clamp(24px, 5vw, 28px);
  flex-shrink: 0;
}

#addInput {
  flex: 1;
  border: none;
  background: transparent;
  font-size: clamp(14px, 3vw, 16px);
  color: var(--on-surface);
  padding: clamp(8px, 2vw, 12px) clamp(4px, 1.5vw, 8px);
  outline: none;
  font-family: inherit;
  min-width: 0;
}

#addInput::placeholder {
  color: var(--on-surface-variant);
  opacity: 0.7;
}

.add-btn {
  width: clamp(40px, 10vw, 48px);
  height: clamp(40px, 10vw, 48px);
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: var(--on-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(103,80,164,0.4), 0 2px 6px rgba(0,0,0,0.2);
  transform: translateZ(0);
  flex-shrink: 0;
}

.add-btn:hover {
  background: var(--primary-container);
  color: var(--on-primary-container);
  transform: scale(1.08) translateZ(10px);
  box-shadow: 0 8px 20px rgba(103,80,164,0.5), 0 4px 10px rgba(0,0,0,0.25);
}

.stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(12px, 3vw, 16px);
  margin-bottom: clamp(12px, 3vw, 20px);
  padding: 0 clamp(4px, 1.5vw, 8px);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.5vw, 8px);
  color: var(--on-surface-variant);
  font-size: clamp(12px, 2.5vw, 14px);
  font-weight: 500;
}

.stat-item .material-symbols-rounded {
  font-size: clamp(18px, 4vw, 20px);
  color: var(--primary);
}

.tasks-container {
  position: relative;
  min-height: 200px;
}

.task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 2vw, 12px);
}

.task-list li {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 12px);
  animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.task-card {
  flex: 1;
  background: var(--surface);
  border-radius: clamp(12px, 3vw, 20px);
  padding: clamp(12px, 3vw, 20px) clamp(16px, 4vw, 24px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 2vw, 16px);
  box-shadow: 0 6px 16px var(--shadow), 0 3px 8px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.1);
  border: 1px solid var(--surface-variant);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: visible;
  transform: translateZ(0);
  transform-style: preserve-3d;
  flex-wrap: wrap;
}

.task-list li.selected .task-card {
  background: var(--primary-container);
  border-color: var(--primary);
}

.task-card:hover {
  transform: translateX(8px) translateY(-2px) translateZ(15px);
  box-shadow: 0 12px 32px var(--shadow), 0 6px 16px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.15);
  border-left: 4px solid var(--primary);
}

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

@keyframes droneHover {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes droneRotor {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes droneFlight {
  0% {
    right: -60px;
    top: 5px;
    opacity: 0;
    transform: scale(0.3) rotate(-5deg);
  }
  10% {
    right: -70px;
    top: -15px;
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
  25% {
    right: -80px;
    top: -18px;
  }
  100% {
    right: -2200px;
    top: -50px;
    opacity: 0;
    transform: scale(0.8) rotate(3deg);
  }
}

@keyframes taskFlyAway {
  0% {
    transform: translateX(0) translateY(0) scale(1);
    opacity: 1;
  }
  25% {
    transform: translateX(0) translateY(0) scale(1);
  }
  75% {
    transform: translateX(1600px) translateY(-55px) scale(0.92);
    opacity: 1;
  }
  100% {
    transform: translateX(1600px) translateY(-55px) scale(0);
    opacity: 0;
  }
}

.task-list li.deleting .task-card {
  animation: taskFlyAway 2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  pointer-events: none;
}

.task-list li.deleting::after {
  content: '';
  position: absolute;
  width: 35px;
  height: 8px;
  right: -30px;
  top: 22px;
  background: 
    linear-gradient(180deg, 
      #6b7c5a 0%, 
      #5a6b4a 15%,
      #4a5a3a 30%, 
      #3a4a2a 60%, 
      #2a3a1a 85%, 
      #1a2a0d 100%);
  border-radius: 1px;
  clip-path: polygon(10% 20%, 90% 20%, 100% 50%, 90% 80%, 10% 80%, 0% 50%);
  box-shadow: 
    0 6px 12px rgba(0,0,0,0.85),
    0 3px 6px rgba(0,0,0,0.7),
    inset 0 2px 3px rgba(120,140,100,0.2),
    inset 0 -2px 3px rgba(0,0,0,0.9),
    0 0 15px rgba(100,120,80,0.25),
    0 1px 0 rgba(110,130,90,0.3),
    inset 0 1px 0 rgba(140,160,110,0.15);
  animation: droneFlight 2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards, droneHover 0.6s ease-in-out infinite;
  z-index: 10;
  transform-style: preserve-3d;
  filter: drop-shadow(0 5px 10px rgba(0,0,0,0.75));
}

.task-list li.deleting::before {
  content: '';
  position: absolute;
  width: 9px;
  height: 9px;
  right: -30px;
  top: 14px;
  background: 
    conic-gradient(from 0deg,
      rgba(60,70,50,1) 0deg,
      rgba(80,90,65,1) 90deg,
      rgba(60,70,50,1) 180deg,
      rgba(80,90,65,1) 270deg,
      rgba(60,70,50,1) 360deg);
  border-radius: 50%;
  border: 2px solid rgba(40,50,30,0.98);
  box-shadow: 
    21px 0 0 -1px rgba(70,80,55,1),
    21px 0 0 1px rgba(40,50,30,0.98),
    0 0 6px rgba(100,110,80,0.5),
    21px 0 6px rgba(100,110,80,0.5),
    inset 0 0 4px rgba(130,140,110,0.4),
    inset -2px -2px 3px rgba(0,0,0,0.85),
    0 4px 8px rgba(0,0,0,0.75),
    21px 4px 8px rgba(0,0,0,0.75),
    0 0 2px rgba(150,160,120,0.25),
    21px 0 2px rgba(150,160,120,0.25);
  animation: droneFlight 2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards, droneRotor 0.02s linear infinite;
  z-index: 11;
  transform-style: preserve-3d;
  filter: blur(0.3px) drop-shadow(0 3px 6px rgba(0,0,0,0.7));
}

.task-checkbox {
  width: clamp(18px, 4vw, 20px);
  height: clamp(18px, 4vw, 20px);
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.task-content {
  flex: 1;
  font-size: clamp(13px, 3vw, 15px);
  color: var(--on-surface);
  line-height: 1.5;
  word-break: break-word;
  padding: clamp(2px, 1vw, 4px) clamp(4px, 1.5vw, 8px);
  border-radius: clamp(6px, 1.5vw, 8px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  min-width: 0;
}

.task-content.editing {
  background: var(--primary-container);
  color: var(--on-primary-container);
  box-shadow: inset 0 0 0 2px var(--primary);
  cursor: text;
}

.edit-btn.save-mode {
  background: var(--primary);
  color: var(--on-primary);
}

.edit-btn.save-mode:hover {
  background: var(--primary);
  color: var(--on-primary);
  transform: scale(1.15);
}

.task-actions {
  display: flex;
  gap: clamp(6px, 1.5vw, 8px);
  flex-shrink: 0;
}

.task-list button {
  width: clamp(36px, 8vw, 40px);
  height: clamp(36px, 8vw, 40px);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: clamp(16px, 3.5vw, 18px);
  box-shadow: 0 3px 8px rgba(0,0,0,0.15), 0 1px 4px rgba(0,0,0,0.1);
  transform: translateZ(0);
}

.edit-btn {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}

.edit-btn:hover {
  background: var(--secondary);
  color: var(--on-secondary);
  transform: scale(1.1) rotate(15deg) translateZ(8px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.2), 0 3px 8px rgba(0,0,0,0.15);
}

.delete-btn {
  background: var(--error-container);
  color: var(--on-error-container);
}

.delete-btn:hover {
  background: var(--error);
  color: var(--on-error);
  transform: scale(1.1) rotate(-15deg) translateZ(8px);
  box-shadow: 0 6px 16px rgba(179,38,30,0.3), 0 3px 8px rgba(0,0,0,0.15);
}

.bulk-delete-btn {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.5vw, 8px);
  padding: clamp(8px, 2vw, 12px) clamp(12px, 3vw, 16px);
  border-radius: clamp(16px, 3vw, 20px);
  border: none;
  background: var(--error);
  color: var(--on-error);
  cursor: pointer;
  font-size: clamp(13px, 3vw, 14px);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(179,38,30,0.3), 0 2px 6px rgba(0,0,0,0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateZ(0);
}

.bulk-delete-btn:hover {
  background: var(--error-container);
  color: var(--on-error-container);
  transform: scale(1.05) translateZ(8px);
  box-shadow: 0 6px 16px rgba(179,38,30,0.4), 0 3px 8px rgba(0,0,0,0.25);
}

.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(40px, 10vw, 60px) clamp(16px, 4vw, 20px);
  text-align: center;
  opacity: 0.6;
}

.empty-state.show {
  display: flex;
  animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.empty-icon {
  font-size: clamp(60px, 15vw, 80px);
  color: var(--primary);
  margin-bottom: clamp(12px, 3vw, 16px);
  opacity: 0.5;
}

.empty-state p {
  font-size: clamp(16px, 4vw, 20px);
  font-weight: 600;
  color: var(--on-surface);
  margin-bottom: clamp(6px, 1.5vw, 8px);
}

.empty-subtitle {
  font-size: clamp(12px, 2.5vw, 14px);
  color: var(--on-surface-variant);
}

@media (max-width: 480px) {
  .task-card:hover {
    transform: translateX(4px) translateY(-1px) translateZ(10px);
  }
  
  .input-card:focus-within {
    transform: translateY(-2px) translateZ(10px);
  }
}

@media (max-width: 360px) {
  .logo-section h1 {
    font-size: 18px;
  }
}
