:root {
  color-scheme: light;
  --primary: #2f6fed;
  --primary-strong: #2559c9;
  --accent: #00a99d;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5c6879;
  --faint: #6b7787;
  --line: #e4e9f1;
  --line-strong: #d3dae6;
  --danger: #bd3d52;
  --danger-strong: #a33145;
  --wash: #f7f9fc;
  --radius: 22px;
  --radius-sm: 12px;
  --shadow: 0 26px 60px -34px rgba(28, 36, 48, 0.32);
  --font: "Outfit", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

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

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

body {
  margin: 0;
  min-height: 100svh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 520px at 88% -12%, rgba(0, 169, 157, 0.1), transparent 62%),
    radial-gradient(760px 420px at -8% 6%, rgba(47, 111, 237, 0.12), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
  color: inherit;
}

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

.noscript {
  margin: 1rem auto;
  width: fit-content;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--danger);
  font-size: 0.85rem;
}

.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;
}

/* ---------- Shell ---------- */

.app {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 4rem) clamp(1rem, 4vw, 3rem);
  display: grid;
  gap: clamp(1.75rem, 4vw, 4.5rem);
  grid-template-columns: 1fr;
  align-items: start;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding-top: 0.25rem;
}

/* ---------- Brand ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  color: var(--text);
}

.brand__mark {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(150deg, var(--primary), #4d86f4);
  box-shadow:
    0 6px 14px -8px rgba(47, 111, 237, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.brand__mark svg {
  width: 1.05rem;
  height: 1.05rem;
}

/* ---------- Heading ---------- */

.eyebrow {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.rail__heading h1 {
  margin: 0;
  font-size: clamp(2.1rem, 4.4vw, 3.15rem);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.lede {
  margin: 1rem 0 0;
  max-width: 34ch;
  font-size: 0.98rem;
  line-height: 1.65;
  color: var(--muted);
}

/* ---------- Progress ---------- */

.progress {
  max-width: 21rem;
  padding-top: 0.25rem;
}

.progress__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.55rem;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.progress__value {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.meter {
  height: 6px;
  border-radius: 999px;
  background: #e2e8f2;
  overflow: hidden;
}

.meter__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.45s var(--ease);
}

/* ---------- Filters ---------- */

.filters {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  width: fit-content;
}

.filter {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.46rem 0.9rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition:
    background-color 0.18s var(--ease),
    color 0.18s var(--ease),
    transform 0.18s var(--ease);
}

.filter:hover {
  color: var(--text);
  background: rgba(228, 233, 241, 0.65);
}

.filter:active {
  transform: scale(0.97);
}

.filter.is-active {
  color: #fff;
  background: var(--text);
}

.filter__count {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  padding: 0.1rem 0.36rem;
  border-radius: 999px;
  background: rgba(28, 36, 48, 0.08);
  color: inherit;
}

.filter.is-active .filter__count {
  background: rgba(255, 255, 255, 0.18);
}

/* ---------- Storage note ---------- */

.storage {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 0.78rem;
  color: var(--faint);
}

.storage__dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 169, 157, 0.14);
}

.storage.is-error {
  color: var(--danger);
}

.storage.is-error .storage__dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(189, 61, 82, 0.14);
}

/* ---------- Sheet ---------- */

.sheet {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 3vw, 2.25rem);
  min-width: 0;
}

/* ---------- Add form ---------- */

.add__label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.add__field {
  display: grid;
  gap: 0.6rem;
}

.add__input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--wash);
  font-size: 0.98rem;
  transition:
    border-color 0.18s var(--ease),
    background-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

.add__input::placeholder {
  color: #7c8798;
}

.add__input:hover {
  border-color: #bfc9d8;
}

.add__input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.12);
}

.add__input.has-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(189, 61, 82, 0.1);
}

.hint,
.error {
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
  line-height: 1.5;
}

.hint {
  color: var(--faint);
}

.error {
  color: var(--danger);
  font-weight: 500;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.8rem 1.15rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color 0.18s var(--ease),
    border-color 0.18s var(--ease),
    color 0.18s var(--ease),
    transform 0.12s var(--ease),
    box-shadow 0.18s var(--ease);
}

.btn:active {
  transform: translateY(1px) scale(0.995);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.btn--primary {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 10px 22px -14px rgba(47, 111, 237, 0.9);
}

.btn--primary:hover:not(:disabled) {
  background: var(--primary-strong);
}

.btn--ghost {
  color: var(--text);
  background: #fff;
  border-color: var(--line-strong);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--wash);
  border-color: #bfc9d8;
}

.btn--danger {
  color: #fff;
  background: var(--danger);
  box-shadow: 0 10px 22px -14px rgba(189, 61, 82, 0.9);
}

.btn--danger:hover:not(:disabled) {
  background: var(--danger-strong);
}

/* ---------- Task list ---------- */

.tasks {
  list-style: none;
  margin: 1.6rem 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.tasks[hidden] {
  display: none;
}

.task {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.95rem 0.35rem;
  border-bottom: 1px solid var(--line);
}

.task.is-entering {
  animation: rise 0.34s var(--ease) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.task__check {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  border: 1.5px solid #bcc6d5;
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    background-color 0.18s var(--ease),
    border-color 0.18s var(--ease),
    transform 0.12s var(--ease);
}

.task__check:hover {
  border-color: var(--primary);
}

.task__check:active {
  transform: scale(0.92);
}

.task__check::after {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(0.5px, -1px) scale(0);
  transition: transform 0.16s var(--ease);
}

.task__check:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.task__check:checked::after {
  transform: rotate(-45deg) translate(0.5px, -1px) scale(1);
}

.task__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.task__title {
  font-size: 0.97rem;
  line-height: 1.45;
  color: var(--text);
  overflow-wrap: anywhere;
  transition: color 0.18s var(--ease);
}

.task__meta {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--faint);
}

.task.is-done .task__title {
  color: var(--faint);
  text-decoration: line-through;
  text-decoration-color: rgba(138, 149, 166, 0.55);
  text-decoration-thickness: 1.5px;
}

.task__actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  opacity: 0.75;
  transition: opacity 0.18s var(--ease);
}

.task:hover .task__actions,
.task:focus-within .task__actions {
  opacity: 1;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition:
    background-color 0.16s var(--ease),
    color 0.16s var(--ease),
    transform 0.12s var(--ease);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover {
  background: var(--wash);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn--danger:hover {
  color: var(--danger);
  background: rgba(189, 61, 82, 0.08);
}

/* ---------- Inline edit ---------- */

.task.is-editing {
  align-items: start;
  padding-top: 0.8rem;
  padding-bottom: 0.8rem;
}

.edit-form {
  display: grid;
  gap: 0.55rem;
  min-width: 0;
  grid-column: 2 / -1;
}

.task.is-editing .task__check {
  margin-top: 0.45rem;
}

.edit-form__input {
  width: 100%;
  padding: 0.62rem 0.75rem;
  border: 1.5px solid var(--primary);
  border-radius: 10px;
  background: #fff;
  font-size: 0.95rem;
  box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.1);
}

.edit-form__input:focus {
  outline: none;
}

.edit-form__input.has-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(189, 61, 82, 0.1);
}

.edit-form__actions {
  display: flex;
  gap: 0.4rem;
}

.btn--small {
  padding: 0.38rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 9px;
}

.btn--small.btn--primary {
  box-shadow: none;
}

/* ---------- Empty state ---------- */

.empty {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3.25rem 1rem 2.75rem;
}

.empty.is-visible {
  display: flex;
}

.empty__art {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  margin-bottom: 1.1rem;
  border-radius: 20px;
  color: var(--primary);
  background: linear-gradient(160deg, rgba(47, 111, 237, 0.1), rgba(0, 169, 157, 0.1));
  border: 1px solid rgba(47, 111, 237, 0.14);
}

.empty__art svg {
  width: 34px;
  height: 34px;
}

.empty h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.empty p {
  margin: 0;
  max-width: 34ch;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--muted);
}

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

.sheet__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.4rem;
}

.remaining {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.link-danger {
  padding: 0.35rem 0.15rem;
  border: 0;
  background: none;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--danger);
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.16s var(--ease), opacity 0.16s var(--ease);
}

.link-danger:hover:not(:disabled) {
  color: var(--danger-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-danger:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  text-decoration: none;
}

/* ---------- Dialog ---------- */

.dialog {
  width: min(440px, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 40px 90px -30px rgba(28, 36, 48, 0.5);
}

.dialog::backdrop {
  background: rgba(24, 32, 44, 0.42);
  backdrop-filter: blur(4px);
}

.dialog[open] {
  animation: dialog-in 0.24s var(--ease) both;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.dialog__panel {
  padding: 1.6rem;
}

.dialog__title {
  margin: 0 0 0.55rem;
  font-size: 1.18rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.dialog__message {
  margin: 0 0 1.5rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.dialog__message strong {
  color: var(--text);
  font-weight: 600;
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
}

/* ---------- Responsive ---------- */

@media (min-width: 900px) {
  .app {
    grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr);
    gap: clamp(2.5rem, 6vw, 5.5rem);
  }

  .rail {
    position: sticky;
    top: clamp(1.25rem, 4vw, 4rem);
  }

  .add__field {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

@media (max-width: 899px) {
  .app {
    padding-top: 2rem;
    gap: 1.75rem;
  }

  .rail {
    gap: 1.6rem;
  }

  .lede {
    max-width: 46ch;
  }

  .progress {
    max-width: none;
  }

  .sheet {
    border-radius: 18px;
  }
}

@media (hover: none) {
  .task__actions {
    opacity: 1;
  }
}

@media (max-width: 420px) {
  .add__field > .btn {
    width: 100%;
  }

  .sheet__foot {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.5rem;
  }

  .task__actions {
    opacity: 1;
  }
}

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