:root {
  --bg: #f5f5f7;
  --bg-col: #ebebef;
  --surface: #ffffff;
  --ink: #1a1a24;
  --ink-soft: #6b6b78;
  --ink-faint: #9a9aa8;
  --primary: #4f46e5;
  --primary-soft: #6366f1;
  --accent: #ec4899;
  --border: #e4e4e9;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.12);
  --low: #94a3b8;
  --med: #3b82f6;
  --high: #f59e0b;
  --urgent: #ef4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  height: 100vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* Topbar */
.topbar {
  flex-shrink: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.top-left, .top-right { display: flex; align-items: center; gap: 12px; }
.logo {
  font-size: 18px; font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--primary);
}
.divider { color: var(--ink-faint); }
.board-picker {
  padding: 7px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  outline: none;
  cursor: pointer;
  min-width: 180px;
}
.icon-btn {
  width: 32px; height: 32px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.icon-btn:hover { background: var(--surface); color: var(--primary); border-color: var(--primary); }

#search {
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  min-width: 220px;
  color: var(--ink);
}
#search:focus { border-color: var(--primary); background: var(--surface); }

.btn-primary {
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: all .15s;
}
.btn-primary:hover { background: var(--primary-soft); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3); }

.btn-ghost {
  padding: 8px 16px;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-soft); }
#delete-task { color: var(--urgent); }
#delete-task:hover { border-color: var(--urgent); }

.back-link {
  font-size: 12px;
  color: var(--ink-soft);
  padding: 6px 10px;
}
.back-link:hover { color: var(--primary); }

/* Board */
.board {
  flex: 1;
  padding: 24px;
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: flex-start;
}
.column {
  flex: 0 0 300px;
  background: var(--bg-col);
  border-radius: 12px;
  padding: 12px;
  display: flex; flex-direction: column;
  max-height: 100%;
}
.column.drag-over {
  background: rgba(79, 70, 229, 0.08);
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
}
.col-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 8px 12px;
}
.col-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--ink);
  text-transform: uppercase;
}
.col-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}
.col-count {
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 100px;
}
.col-actions {
  display: flex; gap: 4px;
}
.col-actions button {
  width: 24px; height: 24px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--ink-faint);
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.col-actions button:hover { background: var(--surface); color: var(--ink); }

.col-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
  display: flex; flex-direction: column;
  gap: 8px;
  min-height: 60px;
}
.col-body::-webkit-scrollbar { width: 6px; }
.col-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.add-task {
  margin-top: 8px;
  padding: 8px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 500;
  width: 100%;
  transition: all .15s;
}
.add-task:hover {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--primary);
}

/* Cards */
.task {
  background: var(--surface);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
  cursor: grab;
  border-left: 3px solid var(--med);
  transition: transform .15s, box-shadow .15s;
  user-select: none;
}
.task:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); transform: translateY(-1px); }
.task:active { cursor: grabbing; }
.task.dragging { opacity: 0.4; transform: rotate(2deg); }
.task.hide { display: none; }

.task[data-priority="low"] { border-left-color: var(--low); }
.task[data-priority="med"] { border-left-color: var(--med); }
.task[data-priority="high"] { border-left-color: var(--high); }
.task[data-priority="urgent"] { border-left-color: var(--urgent); }

.task-tags {
  display: flex; gap: 4px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.task-tag {
  background: var(--bg);
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.task h4 {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 4px;
}
.task-desc {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.45;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.task-foot {
  display: flex; justify-content: space-between; align-items: center;
}
.task-priority {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
}
.task-priority::before {
  content: "●";
  font-size: 8px;
}
.task[data-priority="low"] .task-priority { color: var(--low); }
.task[data-priority="med"] .task-priority { color: var(--med); }
.task[data-priority="high"] .task-priority { color: var(--high); }
.task[data-priority="urgent"] .task-priority { color: var(--urgent); }

.task-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 10px;
  font-weight: 700;
}
.av-AL { background: linear-gradient(135deg, #6366f1, #ec4899); }
.av-BR { background: linear-gradient(135deg, #06b6d4, #6366f1); }
.av-MC { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.av-FS { background: linear-gradient(135deg, #10b981, #06b6d4); }
.av-JB { background: linear-gradient(135deg, #a78bfa, #ec4899); }

/* Modal */
.modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal[hidden] { display: none; }
.modal-bg {
  position: absolute; inset: 0;
  background: rgba(20, 20, 30, 0.5);
  backdrop-filter: blur(4px);
  animation: fadeIn .2s ease;
}
.modal-card {
  position: relative;
  background: var(--surface);
  border-radius: 16px;
  padding: 28px;
  width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp .25s cubic-bezier(.2,.7,.3,1);
}
.modal-sm { max-width: 400px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

#task-form, #board-form { display: flex; flex-direction: column; gap: 16px; }
#task-form label, #board-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
#task-form input, #task-form select, #task-form textarea,
#board-form input {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
#task-form input:focus, #task-form select:focus, #task-form textarea:focus,
#board-form input:focus {
  border-color: var(--primary);
  background: var(--surface);
}
#task-form textarea { resize: vertical; min-height: 70px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 13px; color: var(--ink-soft); }
.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
#delete-task { margin-right: auto; }

@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; }
  .top-right { width: 100%; }
  #search { flex: 1; min-width: 0; }
  .board-picker { min-width: 0; flex: 1; }
  .modal-card { padding: 20px; }
  .form-row { grid-template-columns: 1fr; }
}
