/* Mobile first: the list is read at arm's length on a phone, often mid-task,
   so everything is big and one tap away. Larger screens just get a centred
   column of the same thing. */

:root {
  color-scheme: light dark;
  --bg: #f5f3ee;
  --surface: #ffffff;
  --pressed: #efece4;
  --ink: #1d1f23;
  --muted: #6b6e75;
  --line: #e3dfd5;
  --accent: #2f7d5b;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe8;
  --danger: #b4423a;
  --shadow: 0 1px 2px rgb(40 30 10 / 6%), 0 3px 10px rgb(40 30 10 / 5%);
  --toast-bg: #24262b;
  --toast-ink: #f4f4f5;
  --toast-action: #86dcb0;
  --radius: 18px;
  /* Height of the bottom bar, excluding the safe-area inset; the toast sits
     just above it. Keep in sync with .composer padding + control height. */
  --composer-h: 78px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131416;
    --surface: #1e2024;
    --pressed: #282b30;
    --ink: #eceef1;
    --muted: #989ca5;
    --line: #2d3036;
    --accent: #5cc493;
    --accent-ink: #0c1f15;
    --accent-soft: #1b3127;
    --danger: #f08a80;
    --shadow: none;
    --toast-bg: #eceef1;
    --toast-ink: #17181b;
    --toast-action: #22704f;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }

.sprite { display: none; }

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

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

/* ---- header ------------------------------------------------------------ */

.top, main, .composer-inner {
  width: 100%;
  max-width: 34rem;
  margin-inline: auto;
}

/* Name and Share on one row, the count under the name: a list's name needs
   the width more than "3 left" does. */
.top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  padding: calc(env(safe-area-inset-top) + 22px) 14px 14px 20px;
}

h1 {
  margin: 0;
  font-size: 2.1rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.name {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

/* An input that reads as the heading until it's tapped. Its width is set
   from the mirror by app.js; flex shrinking and the ellipsis handle a name
   longer than the row. */
.name input {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  height: 1.3em;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-overflow: ellipsis;
  -webkit-appearance: none;
  appearance: none;
}

/* Unnamed lists show the default name through the placeholder, in full ink;
   it only fades while editing, so it's clear the field is empty. */
.name input::placeholder { color: inherit; opacity: 1; }
.name input:focus::placeholder { color: var(--muted); }

.name input:focus {
  outline: none;
  box-shadow: 0 2px 0 var(--accent);
}

.name input:disabled { opacity: 1; -webkit-text-fill-color: currentColor; }

.name-edit {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--muted);
  cursor: pointer;
}

.name-edit svg { width: 20px; height: 20px; }
.name:focus-within .name-edit,
.name input:disabled + .name-edit { visibility: hidden; }

.name-mirror {
  position: absolute;
  top: 0;
  left: 0;
  width: max-content;
  white-space: pre;
  visibility: hidden;
  pointer-events: none;
}

/* A line is kept for it even when empty, so the header doesn't jump when the
   list loads. */
.count {
  grid-column: 1 / -1;
  min-height: 1.4em;
  margin: 2px 0 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.share {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px 0 12px;
  border: 1.5px solid var(--line);
  border-radius: 99px;
  background: var(--surface);
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
}

.share:active { background: var(--pressed); }
.share svg { width: 20px; height: 20px; }

main { flex: 1; padding: 0 14px 20px; }

/* ---- tasks ------------------------------------------------------------- */

.tasks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.task {
  display: flex;
  min-height: 72px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.task.enter { animation: enter 0.22s ease-out; }

@keyframes enter {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
}

.task-toggle,
.task-delete {
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.task-toggle {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 6px 14px 16px;
  text-align: left;
  border-radius: var(--radius) 0 0 var(--radius);
}

.task-delete {
  flex: none;
  width: 58px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.task-toggle:active,
.task-delete:active { background: var(--pressed); }
.task-delete:active { color: var(--danger); }

.task-delete svg { width: 22px; height: 22px; }

.check {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 2.5px solid var(--muted);
  border-radius: 50%;
  color: var(--accent-ink);
  transition: background-color 0.2s, border-color 0.2s, transform 0.15s;
}

.check svg {
  width: 19px;
  height: 19px;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.3, 1.6, 0.6, 1);
}

.task-toggle:active .check { transform: scale(0.88); }

.task-title {
  font-size: 1.25rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
  transition: color 0.2s;
}

.is-done .check { background: var(--accent); border-color: var(--accent); }
.is-done .check svg { opacity: 1; transform: none; }
.is-done .task-title {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.is-pending { opacity: 0.55; }

/* ---- done section ------------------------------------------------------ */

.done { margin-top: 20px; }

.done summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 8px 6px;
  color: var(--muted);
  font-weight: 650;
  list-style: none;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  border-radius: 12px;
}

.done summary::-webkit-details-marker { display: none; }

.chevron { width: 20px; height: 20px; transition: transform 0.2s; }
.done[open] .chevron { transform: rotate(90deg); }

.done-count {
  min-width: 1.6em;
  padding: 0 0.45em;
  border-radius: 99px;
  background: var(--line);
  color: var(--ink);
  font-size: 0.85rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.done .tasks { margin-top: 6px; }

.done .task {
  min-height: 60px;
  background: transparent;
  box-shadow: none;
  border: 1.5px solid var(--line);
}

.done .task-title { font-size: 1.1rem; }

/* ---- empty and loading states ------------------------------------------ */

.status,
.empty {
  padding: 56px 16px;
  text-align: center;
  color: var(--muted);
}

.status p { margin: 0 0 12px; }

.retry {
  min-height: 44px;
  padding: 0 20px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}

.empty-icon { width: 72px; height: 72px; }
.empty-icon circle { fill: var(--accent-soft); }
.empty-icon path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-title {
  margin: 14px 0 4px;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 650;
}

.empty-sub { margin: 0 auto; max-width: 26ch; }

.empty-share {
  margin-top: 20px;
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.empty-share:active { transform: scale(0.97); }

/* ---- bottom input bar -------------------------------------------------- */

.composer {
  position: sticky;
  bottom: 0;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.composer-inner { display: flex; gap: 10px; }

.composer input {
  flex: 1;
  min-width: 0;
  height: 54px;
  padding: 0 18px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  /* 16px or more, or iOS Safari zooms the page in on focus. */
  font: inherit;
  font-size: 1.1rem;
}

.composer input::placeholder { color: var(--muted); }

.composer input:focus {
  border-color: var(--accent);
  outline: none;
}

.add {
  flex: none;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s;
}

.add:active { transform: scale(0.94); }
.add svg { width: 26px; height: 26px; }

/* ---- toast ------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--composer-h) + env(safe-area-inset-bottom) + 10px);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100% - 28px);
  min-height: 48px;
  padding: 6px 6px 6px 18px;
  border-radius: 14px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  box-shadow: 0 6px 24px rgb(0 0 0 / 22%);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 10px);
  transition: opacity 0.2s, transform 0.2s, visibility 0s linear 0.2s;
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition-delay: 0s;
}

.toast-text {
  min-width: 0;
  padding: 6px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast-action {
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--toast-action);
  font-weight: 700;
  cursor: pointer;
}

.toast-action[hidden] { display: none; }

/* ---- start, about and not-found pages ---------------------------------- */

.brand,
.intro {
  width: 100%;
  max-width: 34rem;
  margin-inline: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 20px) 20px 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.brand img { border-radius: 7px; }

.brand a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: -8px 0;
  color: inherit;
  text-decoration: none;
}

.intro {
  flex: 1;
  padding: 40px 20px calc(env(safe-area-inset-bottom) + 48px);
}

.intro h1 {
  max-width: 13ch;
  font-size: clamp(2.3rem, 10vw, 3.1rem);
  line-height: 1.04;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.lede {
  max-width: 34ch;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1.45;
}

/* The about page's one loud thing: a list's code, one tile per character,
   drawn again on every tap. Monospace so l, I and 1 or O and 0 can be told
   apart, since capitals matter. */
.address {
  display: block;
  width: 100%;
  max-width: 26rem;
  margin: 20px 0 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: none;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.address-host {
  display: block;
  margin: 0 0 10px;
  color: var(--muted);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.code {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
  max-width: 26rem;
  margin: 0;
  font: 700 clamp(1.35rem, 6.6vw, 1.95rem) / 1 ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

.code span {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 5;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.code .rolling { color: var(--muted); }

.code .set {
  border-color: var(--accent);
  background: var(--accent-soft);
  animation: settle 0.3s cubic-bezier(0.3, 1.6, 0.6, 1);
}

@keyframes settle {
  from { transform: translateY(-7px) scale(1.06); }
}

.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 26rem;
  min-height: 58px;
  padding: 0 24px;
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s;
}

.primary:active { transform: scale(0.98); }
.primary:disabled { cursor: default; opacity: 0.8; }
.lede + .primary { margin-top: 32px; }

.start-error {
  max-width: 26rem;
  margin: 12px 0 0;
  color: var(--danger);
  font-weight: 600;
}

.section {
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.section h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
  font-weight: 700;
}

.section > p:not(.note) {
  max-width: 52ch;
  margin: 0;
  line-height: 1.5;
}

.steps ol {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

/* Numbered in the same circles as a list's check marks. */
.steps li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 14px;
  align-items: center;
  line-height: 1.4;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2.5px solid var(--muted);
  border-radius: 50%;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.note {
  max-width: 52ch;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.more { margin: 36px 0 0; }

.more a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent);
  font-weight: 650;
  text-underline-offset: 3px;
}

.version {
  margin: 48px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

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