:root {
  color-scheme: light dark;
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6a66;
  --line: #e3e1db;
  --accent: #2f7d4f;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --notice: #fff4d6;
  --notice-text: #5c4300;
  --radius: 0.75rem;
  --tap: 2.75rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151614;
    --surface: #1f201d;
    --text: #ecebe6;
    --muted: #9a9993;
    --line: #33342f;
    --accent: #5dbb83;
    --accent-text: #0d1f14;
    --danger: #f2948c;
    --notice: #3a3014;
    --notice-text: #f3dc9a;
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

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

button {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.35;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

button.danger {
  border-color: var(--danger);
  color: var(--danger);
  font-weight: 600;
}

button.link {
  border: none;
  background: none;
  color: var(--muted);
  padding: 0 0.5rem;
  text-decoration: underline;
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  min-height: var(--tap);
  padding: 0 0.875rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

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

/* One centered column on wide screens; full width on phones. */
.bar,
.status,
main {
  max-width: 40rem;
  margin: 0 auto;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: max(0.75rem, env(safe-area-inset-top));
  padding-bottom: 0.25rem;
}

.bar h1 {
  margin: 0;
  font-size: 1.375rem;
}

.account {
  display: flex;
  align-items: center;
  min-width: 0;
  color: var(--muted);
}

.user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  margin: 0.5rem auto 0;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  border-radius: var(--radius);
  background: var(--notice);
  color: var(--notice-text);
  font-size: 0.9375rem;
}

main {
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

/* Login */

.login form {
  display: grid;
  gap: 1rem;
  margin-top: 2rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.login h2 {
  margin: 0;
  font-size: 1.25rem;
}

.login label {
  display: grid;
  gap: 0.375rem;
  font-weight: 600;
}

.login .error {
  margin: 0;
  color: var(--danger);
}

.login .hint {
  margin: 0;
  color: var(--muted);
}

/* The add field stays at the top while scrolling, where the phone keyboard
   cannot cover it. */
.add {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 0;
  background: var(--bg);
}

.add input {
  flex: 1;
  min-width: 0;
}

/* List */

.items {
  margin: 0;
  padding: 0;
  list-style: none;
}

.item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  border-bottom: 1px solid var(--line);
}

.toggle {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0.875rem;
  min-width: 0;
  min-height: 3.25rem;
  padding: 0.5rem 0;
  cursor: pointer;
}

.toggle input {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  accent-color: var(--accent);
}

.body {
  display: grid;
  min-width: 0;
}

.text {
  overflow-wrap: anywhere;
}

.meta,
.pending {
  color: var(--muted);
  font-size: 0.8125rem;
}

.pending {
  font-style: italic;
}

.item:not(.is-pending) .pending {
  display: none;
}

.item.is-checked .text {
  color: var(--muted);
  text-decoration: line-through;
}

.item.is-checked .body {
  opacity: 0.7;
}

.delete {
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
}

.delete svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

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

/* Delete confirmation */

.confirm {
  width: min(24rem, calc(100vw - 2rem));
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.confirm::backdrop {
  background: rgb(0 0 0 / 0.4);
}

.confirm p {
  margin: 0 0 1rem;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
