:root{
  --bg: #eef0fa;
  --surface: #ffffff;
  --ink: #1d1b31;
  --ink-soft: #8b899e;
  --accent: #5b4fe9;
  --accent-soft: #edebfc;
  --success: #21c9a0;
  --danger: #f0506e;
  --ring-track: #e7e5f5;
  --radius: 20px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 15% -10%, #e4e1fb 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #d9f5ee 0%, transparent 55%),
    var(--bg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(20px, 6vh, 64px) 16px;
  padding-bottom: max(clamp(20px, 6vh, 64px), env(safe-area-inset-bottom));
}

.card {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow:
    0 30px 60px -20px rgba(91, 79, 233, 0.25),
    0 8px 20px -10px rgba(29, 27, 49, 0.08);
  overflow: hidden;
}

/* ---------- Header ---------- */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(22px, 4vw, 30px) clamp(20px, 5vw, 32px) 20px;
}

.eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 4px;
  font-weight: 500;
}

h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(26px, 6vw, 32px);
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1;
}

.ring {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  transform: rotate(-90deg);
}
.ring-track {
  fill: none;
  stroke: var(--ring-track);
  stroke-width: 4;
}
.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 113.1;
  stroke-dashoffset: 113.1;
  transition: stroke-dashoffset 0.4s cubic-bezier(0.65, 0, 0.35, 1), stroke 0.3s ease;
}
.ring-progress.complete {
  stroke: var(--success);
}

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

#addForm {
  display: flex;
  gap: 10px;
  padding: 0 clamp(20px, 5vw, 32px) 20px;
}

#taskInput {
  flex: 1;
  min-width: 0;
  font-family: 'Inter', sans-serif;
  font-size: 16px; /* keeps iOS from zooming on focus */
  padding: 13px 16px;
  border: 1.5px solid #eceafa;
  border-radius: 14px;
  background: #fbfaff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
#taskInput:focus {
  border-color: var(--accent);
  background: #fff;
}
#taskInput::placeholder { color: #a9a6bd; }

#addBtn {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease, transform 0.1s ease;
}
#addBtn:hover { background: #4c40db; }
#addBtn:active { transform: scale(0.92); }
#addBtn:focus-visible, #taskInput:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- List ---------- */

#list {
  list-style: none;
  margin: 0;
  padding: 4px 12px 4px;
  min-height: 20px;
}

li.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 12px;
  border-radius: 14px;
  transition: background 0.15s ease;
}
li.item:hover { background: var(--accent-soft); }

.check {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #d7d4ec;
  cursor: pointer;
  touch-action: manipulation;
  position: relative;
  background: #fff;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.check:hover { border-color: var(--accent); }
li.done .check {
  background: var(--success);
  border-color: var(--success);
}
li.done .check::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 3px;
  width: 6px;
  height: 11px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(40deg);
}

.label {
  flex: 1;
  font-size: 15.5px;
  line-height: 1.4;
  word-break: break-word;
  cursor: pointer;
  touch-action: manipulation;
}
li.done .label {
  color: var(--ink-soft);
  text-decoration: line-through;
  text-decoration-color: var(--danger);
  text-decoration-thickness: 1.5px;
}

.remove {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}
li.item:hover .remove,
li.item:focus-within .remove { opacity: 1; }
.remove:hover { color: var(--danger); background: #fde8ec; }
.remove:focus-visible { opacity: 1; outline: 2px solid var(--accent); }

/* On touch devices there's no hover, so always show the delete control */
@media (hover: none) {
  .remove { opacity: 0.55; }
}

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

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 30px 34px 36px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
}
.empty p { margin: 0; }

/* ---------- Footer ---------- */

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px clamp(20px, 5vw, 32px) clamp(20px, 4vw, 26px);
  border-top: 1px solid #f0eefa;
  margin-top: 4px;
}

#count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink-soft);
}

#clearBtn {
  background: none;
  border: none;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  padding: 6px 4px;
  touch-action: manipulation;
}
#clearBtn:hover { text-decoration: underline; }
#clearBtn:disabled { opacity: 0.35; cursor: default; text-decoration: none; }

/* ---------- Accessibility & small screens ---------- */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media (max-width: 380px) {
  header, #addForm, footer { padding-left: 18px; padding-right: 18px; }
}
