:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #8e8e93;
  --line: #e5e5ea;
  --accent: #2e9d5b;
  --accent-text: #ffffff;
  --chip: #e6f4ec;
  --chip-text: #1f6e3f;
  --danger: #e5484d;
  --ok: #34c759;
  --warn: #ff9f0a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f2f2f7;
    --muted: #8e8e93;
    --line: #2c2c2e;
    --accent: #30b465;
    --chip: #17301f;
    --chip-text: #8fe0ad;
    --danger: #ff6369;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}
[hidden] { display: none !important; }
h1 { font-size: 30px; font-weight: 700; margin: 0; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 12px 0 0; }

.screen { min-height: 100%; padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom); max-width: 640px; margin: 0 auto; }
.card { background: var(--card); border-radius: 16px; padding: 24px 20px; box-shadow: var(--shadow); }
.center { margin-top: 18vh; text-align: center; }
.center form { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.logo { width: 72px; height: 72px; border-radius: 16px; margin-bottom: 12px; }

.field {
  width: 100%;
  font: inherit; font-size: 17px; /* ≥16px: iOS не зумит поле */
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  -webkit-appearance: none;
}
.field:focus { border-color: var(--accent); }
.btn {
  font: inherit; font-weight: 600;
  border: 0; border-radius: 12px; padding: 12px 16px;
  background: var(--line); color: var(--text);
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn:active { opacity: .7; }
.link { font: inherit; font-size: 15px; background: none; border: 0; padding: 8px 4px; color: var(--accent); cursor: pointer; }
.link.danger { color: var(--danger); }
.link.muted { color: var(--muted); }

/* шапка */
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 10px) 0 8px;
  margin-top: calc(-1 * env(safe-area-inset-top));
}
.title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.online i { background: var(--ok); }
.status.offline i { background: var(--warn); }
.add { display: flex; gap: 8px; }
.add-btn { width: 50px; flex: none; font-size: 26px; line-height: 1; padding: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips:empty { display: none; }
.chip {
  flex: none; font: inherit; font-size: 15px;
  border: 0; border-radius: 999px; padding: 7px 13px;
  background: var(--chip); color: var(--chip-text); cursor: pointer;
  white-space: nowrap;
}
.chip:active { opacity: .7; }

/* списки */
main { padding: 6px 0 24px; }
.list { list-style: none; margin: 0 0 12px; padding: 0; background: var(--card); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.list:empty { display: none; }
.item { position: relative; overflow: hidden; }
.item + .item .row { border-top: 1px solid var(--line); }
.del-bg {
  position: absolute; inset: 0; background: var(--danger); color: #fff;
  display: flex; align-items: center; justify-content: flex-end; padding-right: 20px; font-weight: 600;
  visibility: hidden;
}
.item.swiping .del-bg { visibility: visible; }
.row {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 10px 14px;
  background: var(--card);
  cursor: pointer; user-select: none; -webkit-user-select: none;
  touch-action: pan-y;
  transition: transform .2s ease;
}
.row.dragging { transition: none; }
.check {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line);
  display: grid; place-items: center;
}
.done .check { background: var(--accent); border-color: var(--accent); }
.done .check::after { content: ""; width: 7px; height: 12px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: translate(0, -1px) rotate(45deg); }
.txt { flex: 1; min-width: 0; }
.txt b { display: block; font-weight: 400; overflow-wrap: anywhere; }
.txt small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.done .txt b { color: var(--muted); text-decoration: line-through; }
.pending .txt small::after { content: " · не отправлено"; color: var(--warn); }

.done-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 4px 2px; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }
.foot { text-align: center; padding: 0 0 24px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.row, .chip { -webkit-touch-callout: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%);
  background: rgba(40, 40, 42, .95); color: #fff; border-radius: 12px;
  padding: 10px 14px; font-size: 15px; display: flex; gap: 14px; align-items: center;
  max-width: calc(100% - 32px); z-index: 10;
}
.toast button { font: inherit; font-weight: 600; background: none; border: 0; color: #7ee2a3; padding: 0; cursor: pointer; }
