/* Task Master - Todoist-inspired theme. Vanilla CSS, no frameworks. */

:root {
  --red: #e44332;
  --red-dark: #c53727;
  --red-tint: #fdecea;
  --ink: #202020;
  --muted: #808080;
  --faint: #a8a8a8;
  --line: #f0f0f0;
  --line-dark: #e4e4e4;
  --sidebar-bg: #f7f7f7;
  --hover: #f5f5f5;
  --bg: #ffffff;
  --card: #ffffff;
  --input-bg: #f3f3f3;
  --p1: #d1453b;   /* high */
  --p2: #eb8909;   /* medium */
  --p3: #246fe0;   /* low */
  --green: #058527; /* due today */
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 12px 32px rgba(0, 0, 0, 0.12);
}

/* ---------- Dark mode (default) ---------- */
[data-theme="dark"] {
  color-scheme: dark;
  --red-tint: #3d2320;
  --ink: #ececec;
  --muted: #a3a3a3;
  --faint: #6e6e6e;
  --line: #2b2b2d;
  --line-dark: #3a3a3d;
  --sidebar-bg: #1e1e20;
  --hover: #2a2a2d;
  --bg: #1c1c1e;
  --card: #262628;
  --input-bg: #2c2c2e;
  --green: #63b57f;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.45), 0 12px 32px rgba(0, 0, 0, 0.55);
}
[data-theme="dark"] .badge.due-today { background: #1d3a27; }
[data-theme="dark"] .badge.recur { background: #20304f; }
[data-theme="dark"] #toast { background: #ececec; color: #1c1c1e; }
[data-theme="dark"] .card { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }
[data-theme="dark"] .subtask-list .del,
[data-theme="dark"] .subtask-list .edit { color: #5c5c5e; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

button { font: inherit; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  text-align: left;
}
.logo-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  box-shadow: 0 4px 14px rgba(228, 67, 50, 0.35);
}
.logo-mark svg { width: 30px; height: 30px; }
.login-card h1 { margin: 0; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
.login-card p { margin: 0 0 6px; font-size: 0.95rem; }
.login-card input { height: 44px; font-size: 1rem; }
.login-card .primary { height: 44px; font-size: 1rem; font-weight: 600; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line-dark);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--red);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.search-wrap {
  flex: 1;
  display: flex;
  justify-content: center;
  position: relative;
  min-width: 0;
}
.search-wrap svg {
  position: absolute;
  left: calc(50% - 200px + 12px);
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  stroke: var(--faint);
  fill: none;
  stroke-width: 2;
  pointer-events: none;
}
#search {
  width: 100%;
  max-width: 400px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: var(--input-bg);
  padding: 0 12px 0 34px;
  font-size: 0.9rem;
  color: var(--ink);
}
#search::placeholder { color: var(--faint); }
#search:focus { outline: 2px solid var(--red); background: var(--bg); outline-offset: -2px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.icon-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.add { color: var(--red); }
.icon-btn.add:hover { background: var(--red-tint); color: var(--red-dark); }
.icon-btn.add svg { width: 22px; height: 22px; }
.text-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 8px 10px;
  border-radius: 8px;
  white-space: nowrap;
}
.text-btn:hover { background: var(--hover); color: var(--ink); }
#menu-btn { display: none; }

/* ---------- Shell / sidebar ---------- */
.shell { display: flex; align-items: stretch; min-height: calc(100vh - 56px); }
#sidebar {
  width: 272px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  padding: 14px 10px;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 0.92rem;
  color: #333;
  text-align: left;
  width: 100%;
}
.nav-item svg {
  width: 19px;
  height: 19px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.nav-item:hover { background: #ececec; }
.nav-item.active { background: #ececec; font-weight: 600; }
.nav-item.active svg { stroke: var(--ink); }
.nav-label { flex: 1; }
.nav-count {
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 18px;
  text-align: right;
}
.nav-item.active .nav-count { color: var(--ink); font-weight: 600; }
.side-foot {
  margin-top: auto;
  padding: 14px 10px 4px;
  font-size: 0.75rem;
  color: var(--faint);
}

/* ---------- Spaces ---------- */
.side-section { margin-top: 20px; }
.side-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 4px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.icon-btn.mini { width: 26px; height: 26px; }
.icon-btn.mini svg { width: 15px; height: 15px; }
.tmeta.space-tag { color: var(--muted); font-weight: 500; }
#sidebar-scrim {
  position: fixed;
  inset: 56px 0 0 0;
  background: rgba(0, 0, 0, 0.32);
  z-index: 35;
}

/* ---------- Main / list ---------- */
#main {
  flex: 1;
  min-width: 0;
  max-width: 820px;
  margin: 0 auto;
  padding: 22px 26px 80px;
  width: 100%;
}
.view-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 2px 0 6px;
}
.view-head h1 { margin: 0; font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; }
#view-subtitle { font-size: 0.82rem; color: var(--muted); }

#task-list { display: flex; flex-direction: column; }
.day-group > h3 {
  margin: 20px 0 2px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
}
.day-group:first-child > h3 { margin-top: 6px; }

.task {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  border-radius: 6px;
  position: relative;
}
.task:hover { background: var(--hover); }

/* Circular checkbox, ring colored by priority */
.check {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  border: 1.6px solid var(--faint);
  background: var(--bg);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 1px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.check svg { width: 12px; height: 12px; opacity: 0; transition: opacity 0.12s; }
.check svg path { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.check:hover svg { opacity: 1; }
.check:hover svg path { stroke: var(--muted); }
.check.pri-high { border-color: var(--p1); }
.check.pri-high:hover { background: var(--p1); }
.check.pri-high:hover svg path { stroke: #fff; }
.check.pri-med { border-color: var(--p2); }
.check.pri-med:hover { background: var(--p2); }
.check.pri-med:hover svg path { stroke: #fff; }
.check.pri-low { border-color: var(--p3); }
.check.pri-low:hover { background: var(--p3); }
.check.pri-low:hover svg path { stroke: #fff; }

.task-body { flex: 1; min-width: 0; cursor: pointer; }
.task-title { font-size: 0.93rem; line-height: 1.45; overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 3px; }
.tmeta { font-size: 0.76rem; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; }
.tmeta.due-overdue { color: var(--p1); font-weight: 600; }
.tmeta.due-today { color: var(--green); font-weight: 600; }
.tmeta.due-future { color: var(--muted); }
.tmeta.recur { color: var(--muted); }
.tmeta.flag-high { color: var(--p1); }
.tmeta.flag-med { color: var(--p2); }
.task-notes {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.sub-toggle {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.76rem;
  padding: 4px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.sub-toggle:hover { color: var(--ink); }
.sub-toggle .chev { display: inline-block; transition: transform 0.15s; font-size: 0.7rem; }
.sub-toggle.open .chev { transform: rotate(180deg); }
.sub-wrap { display: none; margin: 2px 0 0 2px; }
.sub-wrap.open { display: block; }

.row-edit { opacity: 0; margin-top: 2px; }
.task:hover .row-edit { opacity: 1; }
@media (hover: none) { .row-edit { opacity: 0.55; } }

.empty-list {
  padding: 44px 12px;
  text-align: center;
  color: var(--faint);
  font-size: 0.95rem;
}

/* "+ Add task" row */
.add-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: none;
  cursor: pointer;
  padding: 12px 4px;
  font-size: 0.92rem;
  color: var(--muted);
  text-align: left;
}
.add-row .plus {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--red);
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.add-row:hover { color: var(--red); }
.add-row:hover .plus { background: var(--red); color: #fff; }

/* ---------- Board (kanban) ---------- */
#board {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 14px;
  align-items: start;
  overflow-x: auto;
  padding-bottom: 20px;
  max-width: none;
}
.column {
  background: var(--sidebar-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  min-height: 180px;
}
.column h2 {
  margin: 0 0 10px;
  padding: 2px 4px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.count {
  color: var(--faint);
  font-size: 0.75rem;
  font-weight: 400;
}
.cards { display: flex; flex-direction: column; gap: 8px; min-height: 60px; border-radius: 8px; }
.cards.drop-hint { outline: 2px dashed var(--red); outline-offset: 4px; }
.empty-note {
  color: var(--faint);
  font-size: 0.82rem;
  text-align: center;
  padding: 14px 8px;
  border: 1px dashed var(--line-dark);
  border-radius: 8px;
  background: var(--card);
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  padding: 10px 12px;
  cursor: grab;
}
.card:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); }
.card.dragging { opacity: 0.4; }
.card-head { display: flex; align-items: flex-start; gap: 8px; }
.card-head h3 { margin: 0; font-size: 0.9rem; font-weight: 500; flex: 1; overflow-wrap: anywhere; }
.card.done-card h3 { text-decoration: line-through; color: var(--muted); }
.pri { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.pri-high { background: var(--p1); }
.pri-med { background: var(--p2); }
.pri-low { background: var(--p3); }
.notes {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--muted); }
.badge.due-today { background: #e6f4ea; color: var(--green); font-weight: 600; }
.badge.overdue { background: var(--red-tint); color: var(--p1); font-weight: 600; }
.badge.recur { background: #eef2fd; color: var(--p3); }

/* ---------- Subtask checklist ---------- */
.subtask-list { list-style: none; margin: 8px 0 0; padding: 0; }
.subtask-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--line);
}
.subtask-list li:last-child { border-bottom: none; }
.subtask-list li span { flex: 1; overflow-wrap: anywhere; }
.subtask-list li.done span { text-decoration: line-through; color: var(--muted); }
.subtask-list input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--red);
  flex-shrink: 0;
  cursor: pointer;
}
.subtask-list .del {
  border: none; background: none; cursor: pointer;
  color: #d5d5d5; font-size: 1.05rem; line-height: 1; padding: 0 2px;
}
.subtask-list .del:hover { color: var(--p1); }
.subtask-list .edit {
  border: none; background: none; cursor: pointer;
  color: #d5d5d5; font-size: 0.9rem; line-height: 1; padding: 0 2px;
}
.subtask-list .edit:hover { color: var(--ink); }
.sub-edit-input {
  flex: 1;
  width: auto;
  padding: 5px 9px;
  font-size: 0.85rem;
  border: 1px solid var(--red);
  border-radius: 6px;
}
.subtask-add { display: flex; gap: 6px; margin-top: 6px; }
.subtask-add input { flex: 1; }

/* ---------- Forms & buttons ---------- */
input, textarea, select {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--red);
  outline-offset: -1px;
  border-color: var(--red);
}
button.primary {
  background: var(--red);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
button.primary:hover { background: var(--red-dark); }
button.ghost {
  background: var(--card);
  border: 1px solid var(--line-dark);
  color: var(--ink);
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
button.ghost:hover { background: var(--hover); }
button.danger {
  background: var(--red-tint);
  color: var(--p1);
  border: none;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
button.danger:hover { background: #fbd9d4; }
.error {
  background: var(--red-tint);
  color: #8f1d12;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 0.85rem;
}

/* ---------- Modal ---------- */
#modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(32, 32, 32, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 12px;
  overflow-y: auto;
  z-index: 50;
}
#modal {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 22px;
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#modal h2 { margin: 0 0 4px; font-size: 1.15rem; font-weight: 700; }
#modal h3 { margin: 8px 0 0; font-size: 0.9rem; font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.field-row { display: flex; gap: 10px; }
.field-row .field, .field-row input { flex: 1; }
.hint { margin: 0; font-size: 0.76rem; color: var(--muted); }
.modal-actions { display: flex; gap: 8px; margin-top: 8px; align-items: center; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: #202020;
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  z-index: 100;
  max-width: calc(100vw - 32px);
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  #menu-btn { display: inline-flex; }
  #sidebar {
    position: fixed;
    left: 0;
    top: 56px;
    bottom: 0;
    height: auto;
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
    border-right: 1px solid var(--line-dark);
  }
  #sidebar.open { transform: translateX(0); }
  .brand-name { display: none; }
  #main { padding: 16px 14px 80px; }
  #board { grid-template-columns: minmax(270px, 84vw); }
  .search-wrap svg { left: 12px; }
}
