:root {
  --bg: #fbf7f0;
  --surface: #fffdf8;
  --ink: #2a251e;
  --ink-soft: #6b6157;
  --line: #e9dfcf;
  --accent: #c76b3a;
  --accent-ink: #ffffff;
  --danger: #a0371b;
  --ok: #3f7a3c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(42, 37, 30, 0.06), 0 2px 6px rgba(42, 37, 30, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1612;
    --surface: #221d17;
    --ink: #f3ead9;
    --ink-soft: #b5a896;
    --line: #3a3127;
    --accent: #e08355;
    --accent-ink: #1a1612;
    --danger: #d46a4c;
    --ok: #7dbf74;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 1rem 1rem calc(env(safe-area-inset-bottom, 0) + 2rem);
}

h1 { font-size: 1.4rem; margin: 0 0 1rem; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.topbar nav { font-size: 0.95rem; color: var(--ink-soft); }
.topbar .user { font-weight: 600; color: var(--ink); }

a { color: var(--accent); text-decoration: none; }
a:hover, a:focus { text-decoration: underline; }

form label {
  display: block;
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-bottom: 0.3rem;
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  min-height: 44px;
}

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

button {
  font: inherit;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  min-height: 44px;
  cursor: pointer;
}

button:hover, button:focus { filter: brightness(1.05); }
button:active { transform: translateY(1px); }

form > label + input { margin-bottom: 0.8rem; }

form button[type="submit"] {
  margin-top: 0.5rem;
  width: 100%;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.8rem;
}

.add-form .row {
  display: flex;
  gap: 0.5rem;
}

.add-form .row input {
  flex: 1;
  margin-bottom: 0;
}

.add-form .row button {
  flex: 0 0 auto;
  width: auto;
  margin-top: 0;
}

.error {
  background: #f5d9ce;
  color: #5a2211;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid #e7b9a3;
}

@media (prefers-color-scheme: dark) {
  .error {
    background: #3a1a10;
    color: #f3c9b8;
    border-color: #5a2a1a;
  }
}

.muted { color: var(--ink-soft); }

.lists, .tasks {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0;
}

.list-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 1;
  padding: 0.9rem;
  color: var(--ink);
  text-decoration: none;
  min-height: 44px;
}

.list-link:hover { text-decoration: none; background: rgba(199, 107, 58, 0.05); }
.list-name { font-weight: 600; }
.count {
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  font-size: 0.85rem;
}

.task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.chk-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  cursor: pointer;
  min-height: 44px;
  margin: 0;
}

.chk-wrap input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.task-row .title { word-break: break-word; }

.task-row.done .title {
  text-decoration: line-through;
  color: var(--ink-soft);
}

.actions {
  display: flex;
  gap: 0.3rem;
  flex: 0 0 auto;
}

.btn-small {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  min-width: 36px;
  min-height: 36px;
  padding: 0 0.5rem;
  font-size: 0.9rem;
}

.btn-del {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--line);
  min-height: 36px;
  padding: 0 0.6rem;
  font-size: 0.85rem;
  margin-right: 0.5rem;
}

.btn-del:hover { background: rgba(160, 55, 27, 0.08); }

@media (min-width: 640px) {
  .container { padding-top: 2rem; }
}
