:root {
  --bg: #f4f5fb;
  --bg-glow: radial-gradient(1200px 600px at 50% -10%, #e5e7ff 0%, transparent 60%);
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --border: #e3e5ef;
  --text: #1a1c2b;
  --text-muted: #6b7089;
  --accent: #4f46e5;
  --accent-soft: #eceafe;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(24, 26, 48, 0.06), 0 12px 32px -12px rgba(24, 26, 48, 0.18);
  --radius: 14px;
  --ring: 0 0 0 3px rgba(79, 70, 229, 0.28);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1017;
    --bg-glow: radial-gradient(1200px 600px at 50% -10%, #1e2140 0%, transparent 60%);
    --surface: #161923;
    --surface-2: #1c2030;
    --border: #272c3d;
    --text: #eceefb;
    --text-muted: #9aa1bd;
    --accent: #8b87ff;
    --accent-soft: #262a45;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 40px -20px rgba(0, 0, 0, 0.8);
    --ring: 0 0 0 3px rgba(139, 135, 255, 0.35);
  }
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  padding: clamp(1rem, 4vw, 3rem) 1rem;
  background-color: var(--bg);
  background-image: var(--bg-glow);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

.app {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
}

.app__header {
  margin-bottom: 1.25rem;
  text-align: center;
}

.app__title {
  margin: 0;
  font-size: clamp(1.6rem, 5vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app__subtitle {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ---------------------------------------------------------------- composer */

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

.composer__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  font: inherit;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.composer__input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.composer__submit {
  flex: 0 0 auto;
  padding: 0.8rem 1.25rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.composer__submit:hover {
  filter: brightness(1.08);
}

.composer__submit:active {
  transform: translateY(1px);
}

.composer__submit:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.composer__hint {
  min-height: 1.25rem;
  margin: 0 0 0.75rem;
  color: var(--danger);
  font-size: 0.8125rem;
}

/* ------------------------------------------------------------------- panel */

.panel {
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.filters {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: var(--bg);
}

.filters__btn {
  padding: 0.3rem 0.75rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.filters__btn:hover {
  color: var(--text);
}

.filters__btn[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.filters__btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.toolbar__count {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

/* ------------------------------------------------------------------- todos */

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

.todo {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.7rem 0.875rem;
  border-bottom: 1px solid var(--border);
  animation: pop-in 0.18s ease-out;
}

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

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .todo {
    animation: none;
  }
}

.todo__toggle {
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.todo__text {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.15rem 0.25rem;
  border-radius: 8px;
  overflow-wrap: anywhere;
  cursor: text;
}

.todo__text:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.todo--done .todo__text {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.todo__edit {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.15rem 0.35rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--surface-2);
  color: inherit;
  font: inherit;
}

.todo__edit:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.todo__delete {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.todo__delete svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.todo__delete:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

.todo__delete:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.empty {
  margin: 0;
  padding: 2.25rem 1rem;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.9375rem;
}

/* ------------------------------------------------------------------ footer */

.panel__footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.875rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.link-btn {
  padding: 0.25rem 0.25rem;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  border-radius: 6px;
}

.link-btn:disabled {
  color: var(--text-muted);
  cursor: default;
  opacity: 0.6;
}

.link-btn:not(:disabled):hover {
  text-decoration: underline;
}

.link-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.panel__hint,
.footnote {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.footnote {
  margin: 1.25rem 0 0;
  text-align: center;
}
