* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: #111827;
  color: #f9fafb;
}

a {
  color: inherit;
  text-decoration: none;
}

header {
  background: #1f2937;
  padding: 15px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #374151;
}

header h2 {
  margin: 0;
  font-size: 20px;
}

nav {
  display: flex;
  gap: 10px;
}

header a,
nav a {
  background: #374151;
  padding: 8px 12px;
  border-radius: 10px;
}

.container {
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
}

.center {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100dvh;
  padding: 16px;
}

.card {
  background: #1f2937;
  padding: 24px;
  border-radius: 16px;
  border: 1px solid #374151;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.wide {
  width: 100%;
}

.link-card {
  display: block;
  transition: transform 0.15s ease, background 0.15s ease;
}

.link-card:hover {
  transform: translateY(-2px);
  background: #273449;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.group {
  margin-bottom: 32px;
}

.group h2 {
  color: #d1d5db;
}

.muted {
  color: #9ca3af;
}

.login-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

input {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #4b5563;
  background: #111827;
  color: #f9fafb;
  font-size: 16px;
}

button {
  padding: 12px 14px;
  border-radius: 12px;
  border: none;
  background: #2563eb;
  color: white;
  font-weight: bold;
  cursor: pointer;
  font-size: 15px;
}

button:hover {
  background: #1d4ed8;
}

.error {
  background: #7f1d1d;
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 12px;
}

form {
  display: grid;
  gap: 10px;
}

.add-form,
.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-bottom: 16px;
}

.filter-row {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.filter-btn {
  background: #374151;
  padding: 9px 13px;
  border-radius: 10px;
  color: #f9fafb;
}

.filter-btn.active {
  background: #2563eb;
}

.todo-list {
  display: grid;
  gap: 10px;
}

.todo-row {
  display: grid;
  grid-template-columns: 50px 1fr auto;
  gap: 12px;
  align-items: center;
  background: #111827;
  border: 1px solid #374151;
  padding: 12px;
  border-radius: 12px;
}

.todo-row.done span {
  text-decoration: line-through;
  color: #9ca3af;
}

.todo-content {
  display: grid;
  gap: 6px;
}

.todo-content span {
  line-height: 1.4;
  word-break: break-word;
}

.check-button {
  background: #374151;
  min-width: 44px;
  min-height: 44px;
  font-size: 20px;
  border-radius: 10px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  background: #374151;
  color: #c7d2fe;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 13px;
}

.delete-button {
  background: #7f1d1d;
  min-width: 44px;
  min-height: 44px;
}

.delete-button:hover {
  background: #991b1b;
}

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  header {
    flex-direction: column;
    align-items: stretch;
  }

  header h2 {
    font-size: 18px;
  }

  nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  header a,
  nav a,
  button {
    width: 100%;
    text-align: center;
    min-height: 44px;
  }

  .container {
    padding: 12px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 18px;
    border-radius: 14px;
  }

  .add-form,
  .search-form {
    grid-template-columns: 1fr;
  }

  .filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
  }

  .filter-btn {
    text-align: center;
  }

  .todo-row {
    grid-template-columns: 48px 1fr 48px;
    padding: 14px;
  }

  .check-button {
    min-width: 48px;
    min-height: 48px;
    font-size: 22px;
  }

  .delete-button {
    min-width: 48px;
    min-height: 48px;
    padding: 8px;
  }
}
