:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #6d7380;
  --border: #e8ebf2;
  --accent: #2563eb;
  --danger: #e11d48;
  --done: #9aa1b3;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100svh;
  padding: 1rem;
}

.header h1 {
  margin: 0;
  font-size: 1.6rem;
}

.subtitle {
  margin: 0.25rem 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.todo-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.todo-form input,
.todo-form button,
.filter-btn,
.delete-btn,
.clear-completed-btn,
.undo-bar button {
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 1rem;
}

.todo-form input {
  width: 100%;
  min-width: 0;
  padding: 0.75rem 0.9rem;
  background: var(--surface);
}

.todo-form button {
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
  white-space: nowrap;
}

.filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.filter-btn {
  flex: 1;
  padding: 0.55rem 0.7rem;
  background: var(--surface);
}

.filter-btn.active {
  background: #dbeafe;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.todo-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.45rem;
}

.todo-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.7rem 0.8rem;
}

.todo-item-empty {
  grid-template-columns: 1fr;
}

.todo-checkbox {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0.15rem 0 0;
}

.todo-text {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-break: anywhere;
}

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

.delete-btn {
  background: #fff1f2;
  border-color: #ffe4e6;
  color: var(--danger);
  padding: 0.35rem 0.6rem;
  white-space: nowrap;
}

.footer {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.clear-completed-btn {
  background: #fff;
  color: var(--muted);
  border-color: var(--border);
  padding: 0.45rem 0.7rem;
  white-space: nowrap;
}

.clear-completed-btn:disabled {
  opacity: 0.45;
}

.undo-bar {
  margin-top: 0.8rem;
  margin-bottom: calc(env(safe-area-inset-bottom, 0px));
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  background: #111827;
  color: #fff;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.6rem;
}

.undo-bar span {
  flex: 1;
  min-width: 0;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.undo-bar button {
  flex-shrink: 0;
  min-height: 38px;
  background: transparent;
  color: #93c5fd;
  border-color: #374151;
  padding: 0.35rem 0.65rem;
  white-space: nowrap;
}

.hidden {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
}

@media (min-width: 640px) {
  .app {
    padding-top: 1.75rem;
  }
}
