/* --- Theme variables --- */
:root{
  --bg: #eef3f7;
  --card: #ffffff;
  --text: #222;
  --muted: #666;
  --primary: #4caf50;
  --primary-hover: #45a049;
  --danger: #e74c3c;
  --danger-hover: #c0392b;
  --info: #3498db;
  --info-hover: #2980b9;
  --shadow: 0 4px 10px rgba(0,0,0,.1);
  --border: #ddd;

  --prio-high: #ff5757;
  --prio-medium: #f39c12;
  --prio-low: #2ecc71;

  --cat-work: #6c5ce7;
  --cat-personal: #00b894;
  --cat-study: #0984e3;
  --cat-shopping: #e84393;
}

body.dark{
  --bg: #121416;
  --card: #1b1f23;
  --text: #e6e6e6;
  --muted: #a7a7a7;
  --primary: #36c275;
  --primary-hover: #2bab64;
  --danger: #ff6b6b;
  --danger-hover: #e25555;
  --info: #5da9ff;
  --info-hover: #4b92e0;
  --border: #2a2f35;
  --shadow: 0 6px 14px rgba(0,0,0,.35);
}

/* --- Base --- */
*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin:0;
  padding:0;
}

.container{
  max-width: 820px;
  margin: 42px auto;
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: 16px;
  padding: 24px 22px;
  border: 1px solid var(--border);
}

/* --- Header --- */
.header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom: 18px;
}
h1{ margin:0; font-size: 28px; letter-spacing:.2px; }

/* Toggle */
.theme-toggle{
  display:flex; align-items:center; gap:10px; cursor:pointer; user-select:none;
}
.theme-toggle input{ display:none; }
.toggle-slider{
  width:46px; height:26px; border-radius:999px; background:#aaa; position:relative; transition:.2s;
}
.toggle-slider::after{
  content:""; position:absolute; width:20px; height:20px; border-radius:50%;
  background:#fff; top:3px; left:3px; transition:.2s;
}
.theme-toggle input:checked + .toggle-slider{ background: var(--primary); }
.theme-toggle input:checked + .toggle-slider::after{ transform: translateX(20px); }
.toggle-label{ font-size:14px; color: var(--muted); }

/* --- Stats + Progress --- */
.stats{ margin: 6px 0 18px; }
.counts{ display:flex; gap:14px; font-size:14px; color:var(--muted); margin-bottom:10px; }
.progress{
  position:relative; height:12px; background: #e3e7eb; border-radius:999px; overflow:hidden; border:1px solid var(--border);
}
body.dark .progress{ background:#252a30; }
.progress-bar{
  height:100%; background: var(--primary); width:0%; transition: width .3s ease;
}
.progress-label{
  position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);
  font-size: 11px; color:#fff; text-shadow: 0 1px 2px rgba(0,0,0,.35);
}

/* --- Input row --- */
.input-section{
  display:grid;
  grid-template-columns: 1fr 140px 120px 150px 86px;
  gap:10px; margin: 16px 0 20px;
}
input[type="text"], select{
  padding: 11px 12px; font-size: 15px; border:1px solid var(--border);
  border-radius:10px; background: var(--card); color: var(--text);
}
button{
  padding: 11px 12px; border:none; border-radius:10px; cursor:pointer;
  background: var(--primary); color:#fff; transition: background .15s ease, transform .05s ease;
}
button:hover{ background: var(--primary-hover); }
button:active{ transform: translateY(1px); }

/* --- List --- */
.task-list{
  list-style:none; margin:0; padding:0;
}
.task-list li{
  display:grid; grid-template-columns: 1fr auto auto auto;
  gap:10px; align-items:center;
  padding: 12px 14px; margin-bottom:10px; border:1px solid var(--border);
  background: linear-gradient(0deg, transparent, transparent), var(--card);
  border-radius:12px; box-shadow: var(--shadow);
  animation: fadeIn .18s ease-out;
}
@keyframes fadeIn{ from{opacity:0; transform:translateY(4px)} to{opacity:1; transform:none} }

.task-text{
  display:flex; align-items:center; gap:10px; min-width:0;
}
.task-text span{
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; cursor:pointer;
}
.task-text span.completed{
  text-decoration: line-through; color: var(--muted); opacity:.75;
}

/* badges */
.badges{ display:flex; gap:6px; flex-wrap:wrap; }
.badge{
  font-size:11px; padding:3px 8px; border-radius:999px; color:#fff;
  align-self:flex-start;
}
.badge.cat-Work{ background: var(--cat-work); }
.badge.cat-Personal{ background: var(--cat-personal); }
.badge.cat-Study{ background: var(--cat-study); }
.badge.cat-Shopping{ background: var(--cat-shopping); }

.badge.prio-High{ background: var(--prio-high); }
.badge.prio-Medium{ background: var(--prio-medium); color:#222; }
.badge.prio-Low{ background: var(--prio-low); }

/* action buttons */
.actions{ display:flex; gap:6px; }
.icon-btn{
  display:inline-flex; align-items:center; justify-content:center;
  width:38px; height:38px; border-radius:10px; background: var(--info);
}
.icon-btn:hover{ background: var(--info-hover); }
.icon-btn.delete{ background: var(--danger); }
.icon-btn.delete:hover{ background: var(--danger-hover); }
.icon{
  font-size:18px; line-height:1; pointer-events:none;
}

/* Drag indicator */
.task-list li[draggable="true"]{ cursor: grab; }
.task-list li.dragging{ opacity:.6; }

/* Responsive */
@media (max-width: 860px){
  .container{ margin: 24px 10px; }
  .input-section{
    grid-template-columns: 1fr 1fr;
  }
  #category-select, #priority-select, #quick-tasks, #add-btn{
    width:100%;
  }
}

@media (max-width: 420px){
  h1{ font-size:22px; }
  .counts{ flex-direction:column; gap:4px; }
}
