:root {
  --bg: #16121f;
  --bg2: #211b2e;
  --card: #2a2339;
  --line: #3a3150;
  --text: #f6f2ff;
  --muted: #a99fbf;
  --accent: #ff5c8a;
  --accent2: #ffb35c;
  --good: #4ade80;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  overscroll-behavior: none;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100%; padding: calc(16px + var(--safe-top)) 16px calc(24px + var(--safe-bottom)); }
h1 { font-size: 28px; margin: 8px 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 20px; margin: 20px 0 8px; }
p { margin: 6px 0; }
a { color: var(--accent2); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { height: 16px; }
.center { text-align: center; }
.brand { font-weight: 800; font-size: 22px; letter-spacing: -0.03em; }
.brand span { color: var(--accent); }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; min-height: 40px; }

button, .btn {
  font: inherit; border: 0; border-radius: 14px; padding: 12px 16px; cursor: pointer;
  background: var(--card); color: var(--text); font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:disabled { opacity: .5; cursor: default; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #1a0f1f; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--muted); padding: 8px 10px; }
.btn-sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.icon-btn { background: transparent; padding: 6px 8px; color: var(--muted); font-size: 18px; }

input, textarea, select {
  font: inherit; width: 100%; color: var(--text); background: var(--bg2);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 96px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }

.panel { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 12px 0; scrollbar-width: none; }
.tabs button { padding: 8px 12px; border-radius: 999px; font-size: 14px; white-space: nowrap; }
.tabs button.on { background: var(--text); color: var(--bg); }

.list { display: flex; flex-direction: column; gap: 8px; }
.item-row { display: flex; gap: 10px; align-items: center; background: var(--card); border-radius: 14px; padding: 8px; }
.thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--line); flex: none; display: grid; place-items: center; font-size: 22px; overflow: hidden; }
.item-row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-row .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-num { width: 28px; text-align: center; font-weight: 800; color: var(--accent2); flex: none; }
.poll-card { display: block; text-decoration: none; color: inherit; background: var(--card); border-radius: 16px; padding: 14px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--line); font-size: 12px; color: var(--text); }
.check { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }

/* ---------- Swipe screen ---------- */
.swipe-wrap { display: flex; flex-direction: column; min-height: calc(100dvh - 40px - var(--safe-top) - var(--safe-bottom)); }
.progress { height: 6px; background: var(--card); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .3s; }
.question { text-align: center; font-weight: 700; font-size: 18px; margin: 14px 0 10px; }
.stage { position: relative; flex: 1; display: flex; align-items: center; min-height: 360px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.matchup {
  position: relative; width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 24px; padding: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35); will-change: transform; touch-action: pan-y;
}
.matchup.anim { transition: transform .28s ease, opacity .28s ease; }
.side { position: relative; background: var(--card); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; cursor: pointer; border: 3px solid transparent; transition: border-color .1s; }
.side.hot { border-color: var(--good); }
.side .img { aspect-ratio: 1 / 1.1; background: var(--line) center/cover no-repeat; display: grid; place-items: center; font-size: 44px; position: relative; }
.side .img img { width: 100%; height: 100%; object-fit: cover; display: block; position: absolute; inset: 0; }
.side .img.text-only { aspect-ratio: auto; min-height: 220px; padding: 14px; font-size: 22px; font-weight: 700; text-align: center; background: linear-gradient(160deg, #3b2d57, #24203a); line-height: 1.25; word-break: break-word; }
.side .meta { padding: 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side .t { font-weight: 700; font-size: 15px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.side .s { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.side .price { font-weight: 700; color: var(--accent2); font-size: 14px; }
.side .tools { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; }
.side .tools a, .side .tools button { font-size: 12px; padding: 6px 8px; border-radius: 8px; background: var(--bg2); color: var(--text); text-decoration: none; font-weight: 600; }
.stamp { position: absolute; top: 10px; left: 50%; transform: translateX(-50%) rotate(-8deg); font-weight: 900; font-size: 20px; color: var(--good); border: 3px solid var(--good); border-radius: 10px; padding: 2px 10px; opacity: 0; pointer-events: none; background: rgba(22,18,31,.75); z-index: 2; }
.vs { position: absolute; left: 50%; top: 40%; transform: translate(-50%,-50%); width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); font-weight: 900; font-size: 14px; z-index: 3; box-shadow: 0 4px 14px rgba(0,0,0,.4); pointer-events: none; }
.hint { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin: 10px 4px 0; }
.swipe-actions { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; margin-top: 14px; }
.swipe-actions button { padding: 14px; }

#toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; opacity: 0; transition: all .25s; pointer-events: none; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
details.resp { background: var(--card); border-radius: 14px; padding: 10px 12px; }
details.resp summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.resp summary::-webkit-details-marker { display: none; }
details.resp .list { margin-top: 10px; }
.share-box { display: flex; gap: 8px; }
.share-box input { font-size: 14px; }

/* privacy picker */
.vis-pick { display: grid; gap: 8px; }
.vis-opt { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg2); cursor: pointer; }
.vis-opt.on { border-color: var(--accent); }
.vis-opt input { width: auto; margin-top: 3px; accent-color: var(--accent); }

/* photos with captions */
.thumb.thumb-lg { width: 72px; height: 72px; border-radius: 12px; }
.photo-row .caption { padding: 10px 12px; font-size: 15px; }
/* bigger edit / remove buttons in the item list */
#items .icon-btn { min-width: 44px; min-height: 44px; padding: 0; font-size: 20px; background: var(--bg2); border: 1px solid var(--line); color: var(--text); border-radius: 12px; flex: none; }
#items .icon-btn[data-del] { color: #ff8fa8; }

/* segmented, swipeable tabs */
.seg { position: relative; display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin-bottom: 12px; }
.seg button { position: relative; z-index: 1; flex: 1; background: transparent; color: var(--muted); padding: 10px 8px; border-radius: 10px; font-size: 15px; }
.seg button.on { color: var(--text); }
.seg-n { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--line); font-size: 12px; line-height: 18px; }
.seg button.on .seg-n { background: var(--accent); color: #1a0f1f; }
.seg-ink { position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px; border-radius: 10px; background: var(--card); box-shadow: 0 1px 6px rgba(0,0,0,.25); transition: transform .25s ease; }
.seg .seg-ink { width: calc((100% - 8px) / var(--n, 2)); }
.pager { overflow: hidden; touch-action: pan-y; transition: height .25s ease; }
.track { display: flex; align-items: flex-start; }
.track.anim { transition: transform .25s ease; }
.pane { flex: none; padding: 0 1px; }
.badge.hot { background: var(--accent); color: #1a0f1f; }

/* results */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--card); border-radius: 14px; padding: 12px; min-width: 0; }
.stat-l { font-size: 12px; color: var(--muted); }
.stat-v { font-size: 20px; font-weight: 800; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bar { height: 6px; border-radius: 999px; background: var(--line); margin: 6px 0 4px; overflow: hidden; }
.bar > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.pct { font-weight: 800; font-size: 18px; min-width: 36px; text-align: right; color: var(--accent2); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #1a0f1f; font-weight: 800; flex: none; }
.person summary, .item-detail summary { display: flex; align-items: center; gap: 10px; }
.delta { font-size: 12px; font-weight: 700; padding: 2px 6px; border-radius: 8px; flex: none; }
.delta.up { color: var(--good); background: rgba(74,222,128,.12); }
.delta.down { color: #ff8fa8; background: rgba(255,92,138,.12); }
.hist { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 3px; align-items: end; height: 110px; margin: 12px 2px 0; }
.hcol { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.hbar { background: linear-gradient(180deg, var(--accent2), var(--accent)); border-radius: 4px 4px 0 0; min-height: 0; }
.hbar.zero { background: var(--line); height: 2px !important; }
.hlab { font-size: 10px; color: var(--muted); text-align: center; height: 14px; line-height: 14px; }
.facts { display: grid; gap: 4px; font-size: 14px; margin-top: 10px; padding: 0 4px 4px; }
.pager a, .pager img { -webkit-user-drag: none; user-select: none; }

/* item viewer */
.tappable { cursor: zoom-in; }
#viewer { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom)); background: rgba(10, 6, 16, .78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); opacity: 0; transition: opacity .18s ease; }
#viewer.show { opacity: 1; }
.viewer-card { position: relative; width: min(520px, 100%); max-height: 100%; overflow: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: 20px; transform: scale(.96); transition: transform .18s ease; }
#viewer.show .viewer-card { transform: none; }
.viewer-img { display: block; width: 100%; max-height: 65vh; object-fit: contain; background: #000; border-radius: 20px 20px 0 0; }
.viewer-text { padding: 48px 20px 28px; text-align: center; font-size: 26px; font-weight: 800; line-height: 1.25; }
.viewer-body { padding: 14px 16px 16px; }
.viewer-title { font-size: 20px; font-weight: 800; margin-bottom: 2px; }
.viewer-x { position: absolute; top: 10px; right: 10px; z-index: 1; width: 40px; height: 40px; padding: 0; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 18px; }
/* song buttons on the swipe cards */
.song-btns { display: grid; gap: 6px; margin-top: auto; padding-top: 8px; }
.song-btn { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 10px; border-radius: 12px; font-size: 14px; font-weight: 700; text-decoration: none; border: 0; width: 100%; line-height: 1.1; }
.song-btn.preview { background: var(--text); color: var(--bg); }
.song-btn.preview.playing { background: var(--accent); color: #1a0f1f; }
.song-btn.spotify { background: #1ed760; color: #0b0b0b; }.swipe-btn { min-width: 220px; padding: 18px 44px; font-size: 22px; font-weight: 900; letter-spacing: .12em; border: none; border-radius: 999px; color: #06201d; background: linear-gradient(135deg, #3ee0c5, #4aa8ff); box-shadow: 0 8px 24px rgba(62,224,197,.3); }
.swipe-btn:active { transform: scale(.97); }
