:root {
  --bg: #f5f5f0;
  --surface: #ffffff;
  --border: #e8e8e3;
  --text: #1a1a1a;
  --text-muted: #888;
  --accent: #5b6ef5;
  --accent-hover: #4a5ce4;
  --danger: #e05c5c;
  --done: #a0a0a0;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --topnav-height: 56px;
  --sidebar-width: 220px;
}

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

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

/* ---- Top navigation bar ---- */

.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topnav-height);
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 14px;
  z-index: 100;
  box-shadow: var(--shadow);
}

.topnav-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
  user-select: none;
}

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  transition: background 0.15s;
}

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

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: opacity 0.2s;
}

/* ---- Page shell ---- */

.shell {
  display: flex;
  min-height: 100vh;
  padding-top: var(--topnav-height);
}

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

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1.5px solid var(--border);
  position: fixed;
  top: var(--topnav-height);
  left: 0;
  bottom: 0;
  overflow-y: auto;
  padding: 20px 10px;
  z-index: 90;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 6px 10px 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
  background: var(--bg);
  color: var(--text);
}

.sidebar-link.active {
  background: rgba(91, 110, 245, 0.1);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-link svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.sidebar-link.active svg {
  opacity: 1;
}

/* Mobile sidebar backdrop */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 89;
  animation: fade-in 0.2s ease;
}

.sidebar-overlay.visible {
  display: block;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---- Main content area ---- */

.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 40px 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.app {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---- Header ---- */

header {
  padding: 0 4px;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-muted);
  margin-top: 4px;
  font-size: 0.875rem;
}

/* ---- Input ---- */

.input-area {
  display: flex;
  gap: 10px;
}

input[type="text"] {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  box-shadow: var(--shadow);
}

input[type="text"]:focus {
  border-color: var(--accent);
}

input[type="text"]::placeholder {
  color: #bbb;
}

#add-btn {
  padding: 12px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  box-shadow: var(--shadow);
}

#add-btn:hover { background: var(--accent-hover); }
#add-btn:active { transform: scale(0.97); }

/* ---- Filters ---- */

.filters {
  display: flex;
  gap: 6px;
}

.filter-btn {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---- Task list ---- */

#task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: slide-in 0.18s ease;
  transition: opacity 0.2s;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.task-item.done {
  opacity: 0.6;
}

/* Checkbox */
.check {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  background: transparent;
}

.check:hover {
  border-color: var(--accent);
}

.check.checked {
  background: var(--accent);
  border-color: var(--accent);
}

.check.checked::after {
  content: '';
  display: block;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}

/* Task text */
.task-text {
  flex: 1;
  line-height: 1.4;
  word-break: break-word;
}

.done .task-text {
  text-decoration: line-through;
  color: var(--done);
}

/* Delete */
.delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #ccc;
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.task-item:hover .delete-btn {
  opacity: 1;
}

.delete-btn:hover {
  color: var(--danger);
}

/* Empty state */
.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
  font-size: 0.9rem;
}

/* Footer */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 4px;
  color: var(--text-muted);
  font-size: 0.825rem;
}

.clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.825rem;
  text-decoration: underline;
  padding: 0;
}

.clear-btn:hover { color: var(--danger); }

/* ---- Responsive: mobile ---- */

@media (max-width: 767px) {
  .hamburger {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
  }

  .main {
    margin-left: 0;
    padding: 28px 16px;
  }
}
