/* 手機優先的待辦清單樣式。先寫單欄手機版，再用 media query 放大。 */

:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #eef0f8;
  --border: #e2e5f0;
  --text: #171a2b;
  --text-muted: #6b7189;
  --text-faint: #9aa0b5;
  --accent: #4f46e5;
  --accent-soft: #eceafe;
  --danger: #d92d5c;
  --danger-soft: #fdeaef;
  --done: #12a150;
  --shadow-sm: 0 1px 2px rgba(23, 26, 43, 0.06);
  --shadow-md: 0 6px 20px rgba(23, 26, 43, 0.09);
  --radius: 14px;
  --radius-lg: 20px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1020;
    --surface: #171c30;
    --surface-2: #1f2540;
    --border: #2a3151;
    --text: #eef0f8;
    --text-muted: #a2a9c4;
    --text-faint: #767ea0;
    --accent: #8b87ff;
    --accent-soft: #262a52;
    --danger: #ff7597;
    --danger-soft: #3a1e2b;
    --done: #3ddc84;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC",
    "PingFang TC", "Microsoft JhengHei", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: 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;
}

.icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.icon--small {
  width: 15px;
  height: 15px;
  stroke-width: 1.8;
}

/* ---------- 版面 ---------- */

.app {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px
    calc(24px + env(safe-area-inset-bottom));
}

.app__header {
  padding: 8px 4px 0;
}

.app__title {
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

.app__subtitle {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* ---------- 新增列 ---------- */

.composer {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.composer__input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

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

.composer__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.composer__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 52px;
  padding: 0 18px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 0.12s var(--ease), opacity 0.18s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.composer__submit .icon {
  width: 20px;
  height: 20px;
  stroke-width: 2.6;
}

.composer__submit:active {
  transform: scale(0.96);
}

.composer__submit:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.composer__error {
  margin: -6px 4px 0;
  color: var(--danger);
  font-size: 0.875rem;
}

/* ---------- 工具列 ---------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.filters {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}

.filters__btn {
  min-height: 38px;
  padding: 0 14px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.filters__btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.filters__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toolbar__clear {
  min-height: 38px;
  padding: 0 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--danger);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s var(--ease);
}

.toolbar__clear:hover {
  background: var(--danger-soft);
}

.toolbar__clear:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

/* ---------- 清單 ---------- */

.list-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 8px 8px 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  animation: item-in 0.22s var(--ease) both;
}

.item.is-leaving {
  animation: item-out 0.16s var(--ease) both;
}

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

@keyframes item-out {
  to {
    opacity: 0;
    transform: translateX(24px) scale(0.98);
  }
}

.item__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 32px;
  margin-left: 2px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  cursor: pointer;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease),
    color 0.18s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.item__toggle .icon {
  width: 18px;
  height: 18px;
  stroke-width: 3;
}

.item__toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.item.is-done .item__toggle {
  border-color: var(--done);
  background: var(--done);
  color: #fff;
}

.item__text {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 0;
  font-size: 1rem;
  overflow-wrap: anywhere;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.item.is-done .item__text {
  color: var(--text-faint);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.item__delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.item__delete:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.item__delete:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

/* ---------- 空狀態／頁尾 ---------- */

.empty {
  margin: 0;
  padding: 40px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  text-align: center;
  font-size: 0.9375rem;
}

.app__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 2px;
  padding: 0 4px;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.app__counter {
  font-variant-numeric: tabular-nums;
}

.app__note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-faint);
  text-align: right;
}

.noscript {
  max-width: 34rem;
  margin: 24px auto;
  padding: 0 16px;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- 較大螢幕 ---------- */

@media (min-width: 30rem) {
  .app {
    padding-left: 24px;
    padding-right: 24px;
  }

  .app__title {
    font-size: 2rem;
  }

  .composer__submit {
    padding: 0 22px;
  }
}

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