/* ============ Design tokens ============ */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f2f2ef;
  --border: #e7e6e1;
  --border-strong: #d9d8d2;
  --text: #16171a;
  --text-2: #5b5d63;
  --text-3: #9a9ba0;
  --accent: #16171a;
  --accent-contrast: #ffffff;
  --brand: #4f46e5;
  --success: #15803d;
  --danger: #c2410c;
  --danger-bg: #fdf1ea;
  --shadow-sm: 0 1px 2px rgba(17, 18, 22, .04);
  --shadow: 0 1px 2px rgba(17, 18, 22, .04), 0 8px 24px -12px rgba(17, 18, 22, .12);
  --shadow-lg: 0 12px 40px -12px rgba(17, 18, 22, .28);
  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0f11; --surface: #16171a; --surface-2: #1d1e22;
    --border: #26272c; --border-strong: #33343a;
    --text: #f2f2f3; --text-2: #a5a6ad; --text-3: #6c6d74;
    --accent: #f2f2f3; --accent-contrast: #0e0f11;
    --brand: #8b85ff; --success: #4ade80; --danger: #fb923c; --danger-bg: #2a1d16;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
    --shadow-lg: 0 12px 40px -12px rgba(0,0,0,.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0f11; --surface: #16171a; --surface-2: #1d1e22;
  --border: #26272c; --border-strong: #33343a;
  --text: #f2f2f3; --text-2: #a5a6ad; --text-3: #6c6d74;
  --accent: #f2f2f3; --accent-contrast: #0e0f11;
  --brand: #8b85ff; --success: #4ade80; --danger: #fb923c; --danger-bg: #2a1d16;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
  --shadow-lg: 0 12px 40px -12px rgba(0,0,0,.8);
  color-scheme: dark;
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

.shell { max-width: 720px; margin: 0 auto; padding: 0 16px 64px; }

/* ============ Top bar ============ */
.topbar { display: flex; align-items: center; justify-content: space-between; height: 72px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; }
.brand-mark {
  width: 28px; height: 28px; padding: 5px; border-radius: 8px;
  background: var(--accent); color: var(--accent-contrast);
}
.brand-mark svg { stroke-width: 2.6; }
.brand-name { font-size: 16px; }

.icon-btn {
  width: 36px; height: 36px; padding: 8px; border-radius: 10px;
  color: var(--text-2);
  display: inline-grid; place-items: center;
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 32px; height: 32px; padding: 7px; }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.sm svg { width: 18px; height: 18px; }

.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}

/* ============ Hero ============ */
.hero { padding: 40px 0 28px; }
.eyebrow { margin: 0 0 8px; font-size: 13px; color: var(--text-3); font-weight: 500; }
.title { margin: 0; font-size: clamp(28px, 6vw, 38px); font-weight: 600; letter-spacing: -.025em; line-height: 1.15; }
.subtitle { margin: 8px 0 0; color: var(--text-2); font-size: 15px; }
.progress {
  margin-top: 20px; height: 4px; border-radius: 99px;
  background: var(--surface-2); overflow: hidden;
}
.progress-bar {
  display: block; height: 100%; width: 0;
  background: var(--accent); border-radius: inherit;
  transition: width .6s var(--ease);
}

/* ============ Composer ============ */
.composer {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 8px 8px 8px;
  padding-inline-start: 16px;
  box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within { border-color: var(--border-strong); box-shadow: var(--shadow), 0 0 0 4px color-mix(in srgb, var(--brand) 12%, transparent); }
.composer-icon { width: 18px; height: 18px; color: var(--text-3); flex: none; }
.composer-input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  height: 40px; font-size: 15px;
}
.composer-input::placeholder { color: var(--text-3); }
.composer-hint {
  font-family: inherit; font-size: 11px; color: var(--text-3);
  border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px;
}

.btn {
  height: 40px; padding: 0 18px; border-radius: 10px; font-weight: 500; font-size: 14px;
  transition: transform .1s, opacity .15s, background-color .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { opacity: .88; }

/* ============ Toolbar ============ */
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 28px 0 12px;
}
.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-2); border-radius: 11px;
}
.seg {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500; color: var(--text-2);
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.seg:hover { color: var(--text); }
.seg.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.count {
  min-width: 20px; height: 18px; padding: 0 6px; border-radius: 99px;
  font-size: 11.5px; font-variant-numeric: tabular-nums;
  display: inline-grid; place-items: center;
  background: var(--border); color: var(--text-2);
}
.seg.active .count { background: var(--accent); color: var(--accent-contrast); }

.link-btn { font-size: 13px; color: var(--text-3); padding: 6px 4px; transition: color .15s; }
.link-btn:hover:not(:disabled) { color: var(--danger); }
.link-btn:disabled { opacity: .4; cursor: default; }

/* ============ List ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.list { list-style: none; margin: 0; padding: 0; }
.task {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background-color .15s;
  animation: enter .35s var(--ease);
}
.task:last-child { border-bottom: 0; }
.task:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.task.leaving { animation: leave .25s var(--ease) forwards; }

@keyframes enter { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes leave { to { opacity: 0; transform: translateX(-12px); } }

.check {
  flex: none; width: 22px; height: 22px; padding: 3px;
  border-radius: 7px; border: 1.5px solid var(--border-strong);
  color: transparent;
  transition: background-color .2s var(--ease), border-color .2s, color .2s, transform .15s;
}
.check:hover { border-color: var(--text-2); }
.check:active { transform: scale(.88); }
.check svg { stroke-width: 2.8; stroke-dasharray: 20; stroke-dashoffset: 20; transition: stroke-dashoffset .3s var(--ease); }
.task.done .check { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.task.done .check svg { stroke-dashoffset: 0; }

.task-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.task-title {
  font-size: 15px; word-break: break-word;
  transition: color .2s;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat; background-position: right center; background-size: 0 1px;
  transition: background-size .3s var(--ease), color .2s;
  align-self: flex-start;
}
.task.done .task-title { color: var(--text-3); background-size: 100% 1px; }
.task-meta { font-size: 12px; color: var(--text-3); }
.task-edit {
  width: 100%; height: 34px; padding: 0 10px; margin: -4px 0;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); outline: 0;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 12%, transparent);
}
.task.editing .task-meta { display: none; }

.task-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.task:hover .task-actions, .task:focus-within .task-actions { opacity: 1; }
@media (hover: none) { .task-actions { opacity: 1; } }

/* ============ Empty ============ */
.empty { text-align: center; padding: 56px 24px; }
.empty-art {
  width: 56px; height: 56px; margin: 0 auto 16px; padding: 12px;
  border-radius: 16px; background: var(--surface-2); color: var(--text-3);
}
.empty-art svg { stroke-width: 2.2; }
.empty-title { margin: 0; font-size: 16px; font-weight: 600; }
.empty-text { margin: 6px 0 0; color: var(--text-2); font-size: 14px; }

.footnote { text-align: center; color: var(--text-3); font-size: 12.5px; margin-top: 24px; }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px;
  background: var(--text); color: var(--bg);
  padding: 10px 10px 10px 10px; padding-inline-start: 18px;
  border-radius: 12px; box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: toast-in .3s var(--ease);
  max-width: calc(100vw - 32px);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
.toast-action {
  font-weight: 600; padding: 6px 10px; border-radius: 8px;
  color: var(--bg);
  background: color-mix(in srgb, var(--bg) 14%, transparent);
}
.toast-action:hover { background: color-mix(in srgb, var(--bg) 24%, transparent); }

/* ============ Responsive ============ */
@media (max-width: 560px) {
  .hero { padding-top: 20px; }
  .composer-hint { display: none; }
  .btn { padding: 0 14px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .segmented { display: flex; }
  .seg { flex: 1; justify-content: center; padding: 0 6px; }
  .link-btn { align-self: flex-start; }
}

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