:root {
  --green: #2e7d32;
  --green-dark: #1b5e20;
  --bg: #f5f6f4;
  --card: #ffffff;
  --text: #1c1c1c;
  --muted: #7a7f78;
  --line: #e3e6e1;
  --danger: #c62828;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121412;
    --card: #1d201d;
    --text: #ececec;
    --muted: #9aa098;
    --line: #2c302b;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

header#topbar[hidden] { display: none; }
header#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--green);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
header nav { display: flex; gap: 16px; }
header nav a { color: #ffffffcc; text-decoration: none; font-weight: 600; }
header nav a.active { color: #fff; border-bottom: 2px solid #fff; padding-bottom: 2px; }
.user-box { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.badge {
  background: #ff8f00; color: #fff; border-radius: 10px;
  font-size: 12px; padding: 0 6px; margin-left: 2px;
}

main { max-width: 560px; margin: 0 auto; padding: 16px; }

h1 { font-size: 22px; margin: 8px 0 16px; }
h2 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 22px 0 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
}
.card.tappable { cursor: pointer; }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

.progress { height: 5px; background: var(--line); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.progress > div { height: 100%; background: var(--green); border-radius: 3px; }

form.inline { display: flex; gap: 8px; margin: 12px 0; }
input[type=text], input[type=password] {
  flex: 1;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 16px; /* iOS: не зумить при фокусе */
}
button.primary {
  background: var(--green); color: #fff; border: 0;
  padding: 11px 18px; border-radius: 10px; font-size: 15px; font-weight: 600;
  cursor: pointer;
}
button.primary:active { background: var(--green-dark); }
.link-btn {
  background: none; border: 0; color: inherit; cursor: pointer;
  font-size: inherit; padding: 0; text-decoration: underline;
}
.link-btn.danger { color: var(--danger); }
.small { font-size: 13px; }
.muted { color: var(--muted); }

/* пункты списка */
ul.items { list-style: none; margin: 0; padding: 0; }
ul.items li {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; margin-bottom: 8px;
}
ul.items li .txt { flex: 1; word-break: break-word; }
ul.items li.bought .txt { text-decoration: line-through; color: var(--muted); }
ul.items li .who { font-size: 12px; color: var(--muted); white-space: nowrap; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--green); flex-shrink: 0; }
.del-btn {
  background: none; border: 0; color: var(--muted); font-size: 18px;
  cursor: pointer; padding: 2px 6px; flex-shrink: 0;
}

/* авторизация */
.auth-wrap { max-width: 360px; margin: 12vh auto 0; }
.auth-wrap .logo { text-align: center; font-size: 42px; }
.auth-wrap h1 { text-align: center; }
.auth-wrap form { display: flex; flex-direction: column; gap: 10px; }
.auth-tabs { display: flex; gap: 18px; justify-content: center; margin-bottom: 14px; }
.auth-tabs button { font-weight: 600; color: var(--muted); text-decoration: none; }
.auth-tabs button.active { color: var(--green); text-decoration: underline; }
.error { color: var(--danger); font-size: 14px; min-height: 18px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 5px 12px; font-size: 14px;
}

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #333; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 14px; z-index: 100; max-width: 90vw;
}

.back { display: inline-block; margin-bottom: 10px; color: var(--green); text-decoration: none; font-weight: 600; }
