:root {
  color-scheme: light;
  font-family: Inter, "Noto Sans JP", "Yu Gothic", sans-serif;
  color: #243047;
  background: #f5f7fb;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% 5%, rgba(102, 126, 234, 0.15), transparent 27rem),
    radial-gradient(circle at 90% 90%, rgba(72, 187, 120, 0.12), transparent 25rem),
    #f5f7fb;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(92%, 660px);
  margin: 0 auto;
  padding: 72px 0 48px;
}

.app__header {
  margin-bottom: 28px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: #6577d8;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1 {
  margin: 0;
  color: #1c2740;
  font-size: clamp(2.25rem, 8vw, 3.5rem);
  letter-spacing: -0.045em;
}

.subtitle {
  margin: 10px 0 0;
  color: #7a8498;
}

.todo-card {
  overflow: hidden;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 20px 55px rgba(42, 55, 94, 0.12);
  backdrop-filter: blur(14px);
}

.todo-form {
  display: flex;
  gap: 10px;
}

#todo-input {
  min-width: 0;
  flex: 1;
  padding: 14px 16px;
  border: 2px solid #e7eaf2;
  border-radius: 13px;
  outline: none;
  color: #26324a;
  background: #fafbfe;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#todo-input::placeholder {
  color: #a2aabc;
}

#todo-input:focus {
  border-color: #7486e8;
  box-shadow: 0 0 0 4px rgba(116, 134, 232, 0.13);
}

.add-button {
  padding: 0 22px;
  border: 0;
  border-radius: 13px;
  color: white;
  font-weight: 700;
  background: #6577d8;
  box-shadow: 0 8px 18px rgba(101, 119, 216, 0.25);
  transition: transform 0.15s, background 0.2s;
}

.add-button:hover {
  background: #5365c8;
  transform: translateY(-1px);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 26px;
  padding-bottom: 14px;
  border-bottom: 1px solid #edf0f5;
}

#task-count {
  margin: 0;
  color: #7c8699;
  font-size: 0.85rem;
}

.filters {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: #f2f4f8;
}

.filter-button {
  padding: 6px 10px;
  border: 0;
  border-radius: 7px;
  color: #737d91;
  font-size: 0.78rem;
  background: transparent;
}

.filter-button.is-active {
  color: #4659bb;
  font-weight: 700;
  background: white;
  box-shadow: 0 2px 7px rgba(39, 52, 88, 0.1);
}

.todo-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 10px;
  border-radius: 12px;
  transition: background 0.2s;
  animation: appear 0.22s ease-out;
}

.todo-item.is-dragging {
  opacity: 0.35;
  background: #eef1fb;
}

.todo-item.drag-over {
  box-shadow: 0 -2px 0 #6577d8;
}

.todo-item:hover {
  background: #f8f9fc;
}

.drag-handle {
  display: grid;
  width: 22px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  color: #b6bdca;
  cursor: grab;
  touch-action: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.check-label {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 13px;
  cursor: pointer;
}

.custom-check {
  display: grid;
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid #d6dbe7;
  border-radius: 50%;
  transition: 0.2s;
}

.todo-toggle:focus-visible + .custom-check {
  outline: 3px solid rgba(101, 119, 216, 0.25);
  outline-offset: 2px;
}

.todo-toggle:checked + .custom-check {
  border-color: #52b788;
  background: #52b788;
}

.todo-toggle:checked + .custom-check::after {
  width: 8px;
  height: 4px;
  border-bottom: 2px solid white;
  border-left: 2px solid white;
  content: "";
  transform: translateY(-1px) rotate(-45deg);
}

.todo-text {
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.edit-input {
  min-width: 0;
  width: 100%;
  padding: 7px 9px;
  border: 2px solid #7486e8;
  border-radius: 8px;
  outline: none;
  color: #26324a;
  background: white;
  box-shadow: 0 0 0 3px rgba(116, 134, 232, 0.12);
}

.todo-item.is-completed .todo-text {
  color: #a1a8b6;
  text-decoration: line-through;
}

.item-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 2px;
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 9px;
  color: #a0a8b8;
  background: transparent;
  opacity: 0;
  transition: 0.2s;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.todo-item:hover .icon-button,
.icon-button:focus-visible,
.todo-item.is-editing .icon-button {
  opacity: 1;
}

.edit-button:hover {
  color: #5365c8;
  background: #eef0ff;
}

.delete-button:hover {
  color: #dc5c68;
  background: #fff0f1;
}

.empty-state {
  padding: 45px 16px 35px;
  text-align: center;
  color: #9ba4b6;
}

.empty-state span {
  display: grid;
  width: 50px;
  height: 50px;
  margin: 0 auto 14px;
  place-items: center;
  border: 2px dashed #cfd5e0;
  border-radius: 50%;
  font-size: 1.25rem;
}

.empty-state p {
  margin: 0 0 5px;
  color: #737e92;
  font-weight: 700;
}

.empty-state small {
  font-size: 0.78rem;
}

.clear-button {
  display: block;
  margin: 20px auto 0;
  padding: 8px 12px;
  border: 0;
  color: #8b94a5;
  font-size: 0.8rem;
  background: transparent;
}

.clear-button:hover {
  color: #dc5c68;
}

.clear-button[hidden] {
  display: none;
}

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

@keyframes appear {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
}

@media (max-width: 540px) {
  .app {
    padding-top: 42px;
  }

  .todo-card {
    padding: 20px 16px;
    border-radius: 19px;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .filters {
    width: 100%;
  }

  .filter-button {
    flex: 1;
  }

  .icon-button {
    opacity: 1;
  }

  .todo-item {
    gap: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
