:root {
  --bg: #1d2125;
  --header-bg: #161a1d;
  --list-bg: #22272b;
  --list-header-bg: #22272b;
  --card-bg: #2c333a;
  --card-hover: #333c44;
  --input-bg: #22272b;
  --accent: #579dff;
  --accent-hover: #4a8de0;
  --danger: #e2483d;
  --text: #b6c2cf;
  --text-bright: #e8ecef;
  --text-dim: #7b8b9a;
  --border: #2e3d4f;
  --radius: 8px;
  --list-width: 272px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  z-index: 20;
}
header h1 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-bright);
  white-space: nowrap;
}
.header-actions {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ── Board wrap ── */
#board-wrap {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 12px 8px 0;
}

#board {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  height: 100%;
  padding: 0 4px 12px;
  min-width: max-content;
}

/* ── List ── */
.list {
  background: var(--list-bg);
  border-radius: var(--radius);
  width: var(--list-width);
  min-width: var(--list-width);
  max-height: calc(100vh - 70px);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.list-header {
  padding: 10px 12px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.list-name {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-bright);
  cursor: pointer;
  flex: 1;
  padding: 2px 4px;
  border-radius: 4px;
}
.list-name:hover { background: rgba(255,255,255,0.06); }

.list-count {
  font-size: 0.75rem;
  color: var(--text-dim);
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  padding: 1px 7px;
  margin-left: 6px;
  flex-shrink: 0;
}

/* ── Cards area ── */
.list-body {
  overflow-y: auto;
  padding: 0 8px;
  flex: 1;
}

.list-body.drag-over::after {
  content: '';
  display: block;
  height: 4px;
  background: var(--accent);
  border-radius: 4px;
  margin: 4px 0;
  opacity: 0.6;
}

/* ── Card ── */
.card {
  background: var(--card-bg);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.1s, box-shadow 0.1s;
  border: 1px solid transparent;
  position: relative;
}
.card:hover {
  background: var(--card-hover);
  border-color: var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.card.dragging { opacity: 0.35; }

.card-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.label-tag {
  height: 8px;
  width: 40px;
  border-radius: 4px;
  background: var(--accent);
  display: inline-block;
}
.label-tag.urgent { background: #f87168; }
.label-tag.bug    { background: #f87168; }
.label-tag.design { background: #9f8fef; }
.label-tag.test   { background: #60c6d2; }
.label-tag.qa     { background: #fea362; }

.card-title {
  font-size: 0.875rem;
  color: var(--text-bright);
  line-height: 1.4;
  margin-bottom: 4px;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.card-assignee {
  font-size: 0.7rem;
  color: var(--text-dim);
  background: rgba(255,255,255,0.07);
  padding: 1px 6px;
  border-radius: 99px;
}
.card-assignee.ai { color: #9f8fef; background: rgba(159,143,239,0.12); }

.card-due {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.07);
  color: var(--text-dim);
}
.card-due.overdue { background: rgba(248,113,104,0.2); color: #f87168; }
.card-due.today   { background: rgba(255,193,7,0.2);   color: #ffc107; }
.card-due.soon    { background: rgba(96,198,210,0.15); color: #60c6d2; }

/* ── Inline add-card ── */
.list-footer {
  padding: 4px 8px 8px;
  flex-shrink: 0;
}

.btn-add-card {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.875rem;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.1s, color 0.1s;
}
.btn-add-card:hover { background: rgba(255,255,255,0.07); color: var(--text-bright); }
.btn-add-card .plus { font-size: 1rem; font-weight: 300; }

.quick-add { display: none; }
.quick-add.open { display: block; }
.quick-add textarea {
  width: 100%;
  background: var(--card-bg);
  border: 2px solid var(--accent);
  border-radius: 6px;
  color: var(--text-bright);
  font-size: 0.875rem;
  padding: 8px 10px;
  resize: none;
  outline: none;
  font-family: inherit;
  line-height: 1.4;
  min-height: 64px;
}
.quick-add-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  align-items: center;
}
.btn-save-quick {
  background: var(--accent);
  color: #1d2125;
  border: none;
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-save-quick:hover { background: var(--accent-hover); }
.btn-cancel-quick {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.btn-cancel-quick:hover { background: rgba(255,255,255,0.08); color: var(--text-bright); }

/* ── Add List column ── */
.add-list-col {
  width: var(--list-width);
  min-width: var(--list-width);
  flex-shrink: 0;
}

.btn-add-list {
  width: 100%;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: var(--radius);
  color: var(--text-bright);
  font-size: 0.875rem;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.1s;
}
.btn-add-list:hover { background: rgba(255,255,255,0.16); }

.add-list-form {
  background: var(--list-bg);
  border-radius: var(--radius);
  padding: 10px;
  display: none;
}
.add-list-form.open { display: block; }
.add-list-form input {
  width: 100%;
  background: var(--input-bg);
  border: 2px solid var(--accent);
  border-radius: 4px;
  color: var(--text-bright);
  font-size: 0.875rem;
  padding: 7px 10px;
  outline: none;
  margin-bottom: 8px;
}
.add-list-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ── Card Modal ── */
.hidden { display: none !important; }

#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 60px;
  z-index: 100;
}

#modal {
  background: #282e33;
  border-radius: 12px;
  padding: 28px 28px 24px;
  width: 100%;
  max-width: 500px;
  position: relative;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 12px; right: 14px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  width: 28px; height: 28px;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: rgba(255,255,255,0.1); color: var(--text-bright); }

#modal h2 {
  font-size: 1rem;
  color: var(--text-bright);
  margin-bottom: 20px;
  padding-right: 24px;
}

#card-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 14px;
}

#card-form input,
#card-form textarea,
#card-form select {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-bright);
  padding: 8px 10px;
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
}
#card-form input:focus,
#card-form textarea:focus,
#card-form select:focus { border-color: var(--accent); }
#card-form textarea { resize: vertical; min-height: 72px; }
#card-form select option { background: #282e33; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.btn-primary {
  background: var(--accent);
  color: #1d2125;
  border: none;
  border-radius: 4px;
  padding: 8px 20px;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  flex: 1;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 4px;
  padding: 8px 14px;
  font-size: 0.875rem;
  cursor: pointer;
}
.btn-danger:hover { background: rgba(226,72,61,0.1); }

/* ── Checklist badge on card ── */
.card-checklist-badge {
  font-size: 0.7rem;
  color: var(--text-dim);
  background: rgba(255,255,255,0.07);
  padding: 1px 6px;
  border-radius: 4px;
}
.card-checklist-badge.complete { color: #57d9a3; background: rgba(87,217,163,0.12); }

/* ── Named checklists in modal ── */
#checklists-container { margin-top: 20px; }

.checklist-block {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-bottom: 4px;
}

.checklist-block-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.checklist-block-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-bright);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.checklist-block-name:hover { background: rgba(255,255,255,0.06); }
.checklist-pct {
  font-size: 0.75rem;
  color: var(--text-dim);
  min-width: 32px;
  text-align: right;
}
.btn-cl-delete {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 4px;
}
.btn-cl-delete:hover { background: rgba(226,72,61,0.15); color: var(--danger); }

.checklist-bar-wrap {
  background: var(--border);
  border-radius: 99px;
  height: 5px;
  margin-bottom: 10px;
  overflow: hidden;
}
.checklist-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.2s;
}
.checklist-bar.complete { background: #57d9a3; }

.checklist-items { list-style: none; margin-bottom: 8px; }
.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 3px 4px;
  border-radius: 4px;
}
.checklist-item:hover { background: rgba(255,255,255,0.03); }
.checklist-item input[type=checkbox] {
  margin-top: 3px;
  accent-color: var(--accent);
  width: 14px; height: 14px;
  flex-shrink: 0;
  cursor: pointer;
}
.ci-text {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-bright);
  line-height: 1.4;
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 3px;
}
.ci-text:hover { background: rgba(255,255,255,0.06); }
.ci-text.done { text-decoration: line-through; color: var(--text-dim); }
.ci-del {
  background: transparent;
  border: none;
  color: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 4px;
  border-radius: 3px;
}
.checklist-item:hover .ci-del { color: var(--text-dim); }
.ci-del:hover { color: var(--danger) !important; }

.checklist-add-item {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  padding: 0 4px;
}
.checklist-add-item input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-bright);
  padding: 5px 9px;
  font-size: 0.85rem;
  outline: none;
}
.checklist-add-item input:focus { border-color: var(--accent); }

/* ── Add checklist button ── */
#add-checklist-wrap {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 4px;
}
.btn-add-checklist {
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 6px;
  color: var(--text-bright);
  font-size: 0.85rem;
  padding: 7px 14px;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.btn-add-checklist:hover { background: rgba(255,255,255,0.13); }

#add-checklist-inline { padding: 4px 0 8px; }
#add-checklist-inline input {
  width: 100%;
  background: var(--input-bg);
  border: 2px solid var(--accent);
  border-radius: 4px;
  color: var(--text-bright);
  padding: 7px 10px;
  font-size: 0.875rem;
  outline: none;
  margin-bottom: 8px;
}
.checklist-add-actions { display: flex; gap: 6px; align-items: center; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
