:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --border: #e2e1dd;
  --text: #1c1b19;
  --muted: #75726c;
  --accent: #2f6f4e;
  --accent-text: #ffffff;
  --danger: #a33a2c;
  --radius: 12px;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --surface: #1f1f24;
    --border: #32323a;
    --text: #eceae6;
    --muted: #9a978f;
    --accent: #6bbf8e;
    --accent-text: #10221a;
    --danger: #e08b7d;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

.app-header {
  padding: calc(env(safe-area-inset-top) + 1.25rem) 1rem 0.75rem;
}

.app-header h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

main {
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

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

.add input {
  flex: 1;
  min-height: var(--tap);
  padding: 0 0.85rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.add input:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.add button {
  min-height: var(--tap);
  padding: 0 1.1rem;
  font: inherit;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.todo {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.tick {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--tap);
  padding: 0.6rem 0.85rem;
  font: inherit;
  text-align: left;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

.box {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--muted);
  border-radius: 6px;
}

.done .box {
  background: var(--accent);
  border-color: var(--accent);
}

.done .title {
  color: var(--muted);
  text-decoration: line-through;
}

.remove {
  flex: none;
  width: var(--tap);
  font-size: 1.25rem;
  color: var(--muted);
  background: none;
  border: 0;
  border-left: 1px solid var(--border);
  cursor: pointer;
}

.remove:hover {
  color: var(--danger);
}

.empty {
  margin: 2rem 0;
  text-align: center;
  color: var(--muted);
}

.done-group {
  margin-top: 1.5rem;
}

.done-group summary {
  padding: 0.5rem 0;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.done-group .count {
  color: var(--muted);
  opacity: 0.7;
}

.done-group .list {
  margin-top: 0.5rem;
}

.app-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  max-width: 34rem;
  margin: 0 auto;
}

.who {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.who form {
  margin: 0;
}

button.link {
  padding: 0;
  font: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
}

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

.auth {
  max-width: 22rem;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 3rem) 1rem 3rem;
}

.auth h1 {
  margin: 0 0 2rem;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.auth h2 {
  margin: 0 0 1.25rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.auth form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.auth input {
  min-height: var(--tap);
  padding: 0 0.85rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

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

.auth small {
  color: var(--muted);
  font-size: 0.78rem;
}

.auth button[type='submit'] {
  min-height: var(--tap);
  margin-top: 0.25rem;
  font: inherit;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

.auth .error,
.auth .note {
  margin: 0 0 1.25rem;
  padding: 0.7rem 0.85rem;
  font-size: 0.88rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.auth .error {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
}

.auth .note {
  color: var(--muted);
}

.auth .alt {
  margin: 1.25rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.auth a {
  color: var(--accent);
}

.switcher {
  position: relative;
}

.switcher summary {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  cursor: pointer;
  list-style: none;
}

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

.switcher summary::after {
  content: ' ▾';
  font-size: 0.7em;
  color: var(--muted);
}

.switcher nav {
  position: absolute;
  z-index: 10;
  top: 100%;
  left: 0;
  min-width: 12rem;
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.switcher nav a {
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
}

.switcher nav a:hover {
  background: var(--bg);
}

.switcher nav a.new {
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.share {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.share summary {
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

.share .count {
  opacity: 0.7;
}

.members {
  list-style: none;
  margin: 0.75rem 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.members li {
  padding: 0.25rem 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.share button {
  min-height: var(--tap);
  padding: 0 1rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.invite-result p {
  margin: 0.75rem 0 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.invite-result input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 0.85rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
