:root {
  --bg: #ffffff;
  --text: #1c1c1e;
  --muted: #8e8e93;
  --blue: #007aff;
  --red: #ff3b30;
  --line: #ebebed;
  --card: #ffffff;
  --shadow: 0 1px 2px rgba(28, 28, 30, 0.04), 0 8px 24px rgba(28, 28, 30, 0.06);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Pretendard",
    "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
svg {
  max-width: 100%;
  height: auto;
}

button,
input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.app {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 56px 20px 72px;
}

/* ---------- 헤더 ---------- */

.hero {
  margin-bottom: 28px;
}

.hero__date {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.hero__title {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero__sub {
  margin: 6px 0 0;
  font-size: 15px;
  color: var(--muted);
}

/* ---------- 입력창 ---------- */

.composer {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 20px;
}

.composer__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fafafa;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.composer__input::placeholder {
  color: var(--muted);
}

.composer__input:focus {
  background: #ffffff;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.12);
}

.composer__add {
  flex: 0 0 auto;
  padding: 14px 22px;
  border: 0;
  border-radius: 14px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.18s ease, background 0.18s ease;
}

.composer__add:hover:not(:disabled) {
  background: #0a6fdc;
}

.composer__add:active:not(:disabled) {
  transform: scale(0.97);
}

.composer__add:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ---------- 카드 ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  /* fill-mode 없이 — 끝난 뒤 삭제 트랜지션이 정상 동작하도록 */
  animation: item-in 0.26s ease;
}

.item:last-child {
  border-bottom: 0;
}

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

.item--leaving {
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.item--busy {
  opacity: 0.55;
}

.item__box:disabled,
.item__delete:disabled {
  cursor: default;
}

.item__box {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin: 1px 0 0;
  border: 1.5px solid #d3d3d8;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  position: relative;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.12s ease;
}

.item__box:hover {
  border-color: var(--blue);
}

.item__box:active {
  transform: scale(0.9);
}

.item__box:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.18);
}

.item__box::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 3px;
  width: 6px;
  height: 11px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0.4);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.item__box:checked {
  background: var(--blue);
  border-color: var(--blue);
}

.item__box:checked::after {
  opacity: 1;
  transform: rotate(45deg) scale(1);
}

.item__text {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  padding-top: 1px;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: var(--text);
  transition: color 0.25s ease;
}

.item__text::after {
  content: "";
  position: absolute;
  left: 0;
  top: 52%;
  width: 100%;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.item--done .item__text {
  color: var(--muted);
}

.item--done .item__text::after {
  transform: scaleX(1);
}

.item__delete {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -2px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--red);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
  transition: background 0.18s ease, opacity 0.18s ease, transform 0.12s ease;
}

.item__delete:hover {
  background: rgba(255, 59, 48, 0.1);
  opacity: 1;
}

.item__delete:active {
  transform: scale(0.9);
}

.item__delete:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.18);
}

/* ---------- 상태(로딩/빈/에러) ---------- */

.state {
  display: none;
  padding: 44px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  margin: 0;
}

.state.is-visible {
  display: block;
}

.state__icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 122, 255, 0.1);
  color: var(--blue);
  font-size: 22px;
  font-weight: 700;
}

.state__title {
  margin: 0;
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
}

.state__desc {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.state--error .state__title {
  color: var(--red);
}

.state__retry {
  margin-top: 14px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  color: var(--blue);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease;
}

.state__retry:hover {
  background: #f5f5f7;
}

/* ---------- 카운터 ---------- */

.card__footer {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: #fcfcfd;
}

.counter {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.counter--sub {
  font-weight: 500;
  color: var(--muted);
}

.footnote {
  margin: 18px 2px 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* ---------- 토스트 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(28, 28, 30, 0.94);
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 10px 30px rgba(28, 28, 30, 0.22);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
  z-index: 50;
}

.toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.toast.is-error {
  background: rgba(255, 59, 48, 0.96);
}

/* ---------- 모바일 ---------- */

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

  .app {
    padding: 36px 16px 56px;
  }

  .hero__title {
    font-size: 30px;
  }

  .composer {
    flex-wrap: wrap;
  }

  .composer__input {
    flex: 1 1 100%;
  }

  .composer__add {
    flex: 1 1 100%;
    padding: 13px 18px;
  }

  .item {
    padding: 14px 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
