:root {
  color-scheme: light;
  --bg: #faf8f3;
  --fg: #1f1e1b;
  --muted: #8a867d;
  --line: #e7e3da;
  --field: #ffffff;
  --accent: #2f6b4f;
  --accent-fg: #ffffff;
  --danger: #b3261e;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b1a18;
  --fg: #ece9e2;
  --muted: #8f8b82;
  --line: #302e2a;
  --field: #24231f;
  --accent: #7fbf9c;
  --accent-fg: #11201a;
  --danger: #f2b8b5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* No double-tap zoom, like a native app. Pinch zoom keeps working. */
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }

button,
label,
summary { -webkit-user-select: none; user-select: none; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-size: 17px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 36rem;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top) + 28px)
    calc(env(safe-area-inset-right) + 16px)
    calc(env(safe-area-inset-bottom) + 48px)
    calc(env(safe-area-inset-left) + 16px);
}

.header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.theme-toggle {
  flex: none;
  width: 44px;
  height: 44px;
  margin-right: -10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
}

h1 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: inherit;
  letter-spacing: inherit;
  text-align: left;
  overflow-wrap: break-word;
}

.title #list-name { min-width: 0; }
.title:focus-visible { outline: none; text-decoration: underline; text-underline-offset: 6px; }

.chevron { font-size: 1.1rem; }
.title[aria-expanded="true"] .chevron { display: inline-block; transform: rotate(180deg); }

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: 0.4; cursor: default; }

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

input[type="text"],
input[type="password"] {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  color: var(--fg);
  font: inherit;
  font-size: 17px;
}

.status {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--line);
  font-size: 0.9rem;
}

.error {
  margin: 8px 2px 0;
  color: var(--danger);
  font-size: 0.9rem;
}

/* Add form */

.add { display: flex; gap: 8px; }

.add button {
  flex: none;
  width: 50px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 1.6rem;
  line-height: 1;
}

/* List */

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

.list li {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.list label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 12px 0;
  overflow-wrap: anywhere;
  cursor: pointer;
}

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  display: grid;
  place-content: center;
  width: 28px;
  height: 28px;
  margin: 0;
  border: 2px solid var(--muted);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

input[type="checkbox"]::after {
  content: "";
  width: 7px;
  height: 13px;
  border: solid var(--accent-fg);
  border-width: 0 2.5px 2.5px 0;
  transform: translateY(-1px) rotate(45deg);
  opacity: 0;
}

input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::after { opacity: 1; }
input[type="checkbox"]:disabled { cursor: default; opacity: 0.5; }

.delete {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
}

.delete:hover:not(:disabled) { color: var(--fg); }

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

/* Lists panel */

.lists-panel .list { margin: 0 0 16px; }

.list-select {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 12px 0;
  border: 0;
  background: none;
  text-align: left;
  overflow-wrap: anywhere;
}

.list-select[aria-current="true"] { font-weight: 650; }
.count { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Completed section */

.done { margin-top: 40px; }

.done summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  list-style: none;
  cursor: pointer;
}

.done summary::-webkit-details-marker { display: none; }
.done summary::before { content: "›"; width: 1ch; font-size: 1.1rem; }
.done[open] summary::before { transform: rotate(90deg); }

.link {
  padding: 10px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.done .list { margin-top: 4px; }
.done .list span { color: var(--muted); text-decoration: line-through; }
.done input[type="checkbox"]:checked { background: var(--muted); border-color: var(--muted); }

/* Login */

.login form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login h1 { margin-bottom: 20px; }
.login label { color: var(--muted); font-size: 0.9rem; }

.login button {
  padding: 14px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
