/* Colors follow the Telegram theme; fallbacks are for a plain browser (dev). */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #efeff4);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #fff));
  --text: var(--tg-theme-text-color, #000);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  --sep: color-mix(in srgb, var(--hint) 25%, transparent);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

main { padding: 12px 12px 96px; max-width: 640px; margin: 0 auto; }

h1 { font-size: 22px; margin: 8px 4px 12px; }

.hint { color: var(--hint); font-size: 14px; }
.center { text-align: center; padding: 24px 8px; }

.card {
  background: var(--card);
  border-radius: 12px;
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  overflow: hidden;
}
.card:empty { display: none; }

input, textarea, button { font: inherit; color: inherit; }
input, textarea { background: transparent; border: 0; outline: 0; min-width: 0; }

.title {
  width: 100%;
  font-size: 24px;
  font-weight: 700;
  padding: 6px 4px 2px;
}
#counts { padding: 0 4px 10px; }

/* ── items ───────────────────────────────────────────────── */

.item {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 48px;
  padding: 0 4px 0 6px;
  border-bottom: 1px solid var(--sep);
  background: var(--card);
}
.item:last-child { border-bottom: 0; }

.state {
  flex: none;
  width: 40px; height: 40px;
  border: 0; background: none; padding: 0;
  font-size: 22px;
  cursor: pointer;
}

.text {
  flex: 1;
  padding: 12px 2px;
  font-size: 17px;
}
.item.strike .text { color: var(--hint); text-decoration: line-through; }
.item.bold .text { font-weight: 600; }
.item.italic .text { font-style: italic; }

.del, .handle {
  flex: none;
  width: 36px; height: 40px;
  border: 0; background: none; padding: 0;
  color: var(--hint);
  font-size: 18px;
  cursor: pointer;
}
.handle { touch-action: none; cursor: grab; font-size: 20px; }

.item.dragging {
  position: relative;
  z-index: 2;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  border-radius: 8px;
  opacity: .95;
}

/* ── list picker ─────────────────────────────────────────── */

#lists li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--sep);
  cursor: pointer;
}
#lists li:last-child { border-bottom: 0; }

.row { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 16px; }
.row input { flex: 1; padding: 8px 0; }

/* ── buttons ─────────────────────────────────────────────── */

.pill {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
}

#actions { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 8px; }
.link {
  border: 0; background: none;
  color: var(--accent);
  padding: 10px;
  font-size: 15px;
  cursor: pointer;
}
.link.danger { color: var(--danger); }

/* ── add bar, pinned to the bottom ───────────────────────── */

#add-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--sep);
}
#add {
  flex: 1;
  resize: none;
  max-height: 140px;
  padding: 9px 12px;
  border-radius: 18px;
  background: var(--bg);
  font-size: 17px;
}
#add-bar .pill { border-radius: 50%; width: 40px; height: 40px; padding: 0; font-size: 22px; }

#toast {
  position: fixed;
  left: 50%; bottom: 84px;
  transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff;
  padding: 8px 14px; border-radius: 10px;
  font-size: 14px;
  pointer-events: none;
}

[hidden] { display: none !important; }
