:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #6e6e73;
  --line: #e5e5ea;
  --accent: #0a84ff;
  --done: #34c759;
  --danger: #ff3b30;
  --chip: #eef3ff;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f5f5f7;
    --muted: #98989d;
    --line: #2c2c2e;
    --chip: #1a2a44;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 640px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom)); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
.muted { color: var(--muted); text-align: center; margin-top: 40px; }
.err { color: var(--danger); min-height: 1.4em; }
.link { color: var(--accent); padding: 10px 4px; font-size: 15px; }
.danger { color: var(--danger); }

#login { margin-top: 20vh; text-align: center; }
#login form { display: grid; gap: 10px; max-width: 320px; margin: 0 auto; }
#login button { background: var(--accent); color: #fff; padding: 11px; border-radius: 10px; }

#tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 12px; scrollbar-width: none; }
#tabs::-webkit-scrollbar { display: none; }
#tabs button {
  white-space: nowrap; padding: 7px 14px; border-radius: 999px; background: var(--card);
  border: 1px solid var(--line); font-size: 15px;
}
#tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#tabs .count { opacity: .7; margin-left: 4px; font-size: 13px; }

#add-form { display: flex; gap: 8px; margin-bottom: 10px; position: sticky; top: 0; background: var(--bg); padding: 4px 0 6px; z-index: 2; }
#add-input { flex: 1; font-size: 17px; }
#add-place { width: auto; max-width: 38%; color: var(--muted); }

ul { list-style: none; margin: 0; padding: 0; }
#items, #done-items { background: var(--card); border-radius: 12px; overflow: hidden; }
#items:empty { display: none; }
li.item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-bottom: 1px solid var(--line);
  user-select: none;
}
li.item:last-child { border-bottom: 0; }
.check {
  flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted);
  display: grid; place-items: center; transition: background .15s, border-color .15s;
}
li.done .check { background: var(--done); border-color: var(--done); }
li.done .check::after { content: "✓"; color: #fff; font-size: 14px; font-weight: 700; }
.body { flex: 1; min-width: 0; }
.title { overflow-wrap: anywhere; }
li.done .title { text-decoration: line-through; color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; font-size: 13px; color: var(--muted); }
.chip { background: var(--chip); color: var(--accent); border-radius: 6px; padding: 1px 7px; text-decoration: none; }
.chip::before { content: "📍 "; font-size: 11px; }
.ask { color: var(--text); font-style: italic; }
.more { flex: none; color: var(--muted); padding: 6px 7px; font-size: 20px; line-height: 1; }

#place-bar { display: grid; gap: 6px; margin-bottom: 10px; }
.place-row {
  display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 12px; padding: 8px 10px;
}
.place-name { flex: 1; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.place-count { font-weight: 400; color: var(--muted); }
.pill {
  flex: none; font-size: 14px; padding: 7px 11px; border-radius: 999px; background: var(--chip); color: var(--accent);
  text-decoration: none; white-space: nowrap;
}

/* Показать продавцу: всегда белый фон и чёрный текст — максимальный контраст на солнце */
#show {
  position: fixed; inset: 0; z-index: 50; background: #fff; color: #000;
  display: flex; flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.show-top { display: flex; align-items: center; gap: 14px; font-size: 18px; color: #555; }
.show-top #show-count { flex: 1; }
.show-top a { color: #0a84ff; text-decoration: none; font-size: 17px; }
.show-top button { font-size: 26px; color: #555; padding: 4px 8px; }
.show-card {
  flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; gap: 3vh; cursor: pointer; user-select: none; -webkit-user-select: none;
}
.show-ask { font-weight: 800; line-height: 1.1; overflow-wrap: anywhere; letter-spacing: -0.01em; }
.show-qty { font-size: 9vw; font-weight: 700; color: #111; }
.show-qty:empty, .show-title:empty { display: none; }
.show-title { font-size: 5vw; color: #666; }
.show-hint { text-align: center; color: #999; font-size: 13px; }
@media (min-width: 700px) {
  .show-qty { font-size: 56px; }
  .show-title { font-size: 28px; }
}

#done-wrap { margin-top: 14px; }
#clear-done { display: block; margin: 6px auto 0; }

dialog {
  border: 0; border-radius: 16px; padding: 20px; width: min(92vw, 440px);
  background: var(--card); color: var(--text); box-shadow: 0 10px 40px #0004;
}
dialog::backdrop { background: #0006; }
dialog form { display: grid; gap: 12px; }
dialog label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
dialog label.check { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text); width: auto; height: auto; border: 0; border-radius: 0; }
dialog label.check input { width: auto; }
dialog .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
dialog textarea { min-height: 7.5em; resize: vertical; line-height: 1.4; }
dialog .actions { display: flex; gap: 8px; align-items: center; }
dialog .actions span { flex: 1; }
dialog .primary { background: var(--accent); color: #fff; padding: 9px 16px; border-radius: 10px; }
dialog .secondary { padding: 9px 12px; color: var(--muted); }

/* фото товара */
img.thumb { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; background: #fff; border: 1px solid #0001; flex: none; cursor: zoom-in; }
.show-img { max-width: 100%; max-height: 38vh; object-fit: contain; border-radius: 12px; }
.show-img[hidden] { display: none; }
