:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e4e8;
  --text: #1f2328;
  --text-muted: #6a737d;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --overdue: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
}

.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-title {
  font-size: 20px;
  margin: 0;
}

.new-list-form {
  display: flex;
  gap: 8px;
}

.list-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s ease;
}

.list-item:hover {
  background: var(--bg);
}

.list-item--active {
  background: #eff6ff;
  border-color: var(--primary);
}

.list-item__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item__count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 999px;
  padding: 1px 8px;
}

/* ---------- Main ---------- */

.main {
  padding: 32px 40px;
  overflow-y: auto;
}

.main__content {
  max-width: 720px;
  margin: 0 auto;
}

.list-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.list-header h2 {
  font-size: 24px;
  margin: 0;
  flex: 1;
  word-break: break-word;
}

.new-todo-form {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.new-todo-form .input--title {
  flex: 1;
}

.todo-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.todo-item__checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.todo-item__body {
  flex: 1;
  min-width: 0;
}

.todo-item__title {
  margin: 0;
  word-break: break-word;
}

.todo-item__title--done {
  text-decoration: line-through;
  color: var(--text-muted);
}

.todo-item__due {
  font-size: 12px;
  color: var(--text-muted);
}

.todo-item__due--overdue {
  color: var(--overdue);
  font-weight: 600;
}

/* ---------- Forms & buttons ---------- */

.input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: #fff;
  color: var(--text);
}

.input:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

.btn {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg);
}

.btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn--primary:hover {
  background: var(--primary-hover);
}

.btn--danger {
  color: var(--danger);
  border-color: transparent;
  background: transparent;
}

.btn--danger:hover {
  background: #fee2e2;
}

.btn--icon {
  padding: 4px 8px;
  font-size: 12px;
}

/* ---------- States ---------- */

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 16px;
}

.empty-state h3 {
  margin: 0 0 4px;
  color: var(--text);
}

.error-banner {
  background: #fee2e2;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

@media (max-width: 640px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .new-todo-form {
    flex-wrap: wrap;
  }
}
