:root {
  --bg: #12141a;
  --surface: #1b1e27;
  --surface-2: #232734;
  --border: #2e3342;
  --text: #e7e9ee;
  --muted: #9aa1b2;
  --accent: #f5a623;
  --accent-dim: #6b4b12;
  --good: #4cc38a;
  --bad: #e5534b;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over display:flex rules. */
[hidden] { display: none !important; }

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

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 6px;
  max-width: 860px;
  margin: 0 auto;
}

h1 { font-size: 1.25rem; margin: 0; display: inline-flex; align-items: center; gap: 6px; }
h1 .logo { height: 1.7em; width: auto; }
h2 { font-size: 1.05rem; margin: 28px 0 10px; color: var(--muted); }

.header-right { display: flex; gap: 8px; align-items: center; }

.chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.85rem;
  white-space: nowrap;
}
.banner {
  max-width: 860px;
  margin: 8px auto 0;
  padding: 8px 16px;
  color: var(--accent);
  font-size: 0.85rem;
  text-align: center;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 10px 16px 0;
  max-width: 860px;
  margin: 0 auto;
}
.tab {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
  color: var(--muted);
  padding: 10px;
  font-size: 0.95rem;
  cursor: pointer;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); background: var(--surface-2); }

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

.cards { display: flex; flex-direction: column; gap: 12px; }

.card {
  display: flex;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.card .cover {
  align-self: stretch;
  height: auto;
  width: auto;
  min-width: 84px;
  min-height: 84px;
  /* Cap the stretch: an uncapped square cover widens as the card grows,
     squeezing the text taller and growing itself again. */
  max-height: 148px;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
}
.card .body { flex: 1; min-width: 0; }
.card .title { font-weight: 600; margin: 0 0 2px; }
.card .meta { color: var(--muted); font-size: 0.85rem; margin: 0 0 4px; }
.card .summary {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 6px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.read-more {
  color: var(--accent);
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-block;
  margin: 5px 0 0;
}
.read-more:hover { text-decoration: underline; }
.detail-trigger { cursor: pointer; }
.title.detail-trigger:hover { text-decoration: underline; }
.cover.detail-trigger:hover { outline: 2px solid var(--accent); outline-offset: 1px; }

.modal.detail { max-width: 580px; max-height: 85vh; overflow-y: auto; }
.detail-body { margin-top: 12px; }
.detail-summary {
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 8px 0 14px;
  white-space: pre-wrap;
}
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }

#club-poll { margin-top: 28px; }
.poll-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.poll-head h2 { margin: 0; }
.poll-note { margin: 4px 4px 12px; }
.card .byline { color: var(--muted); font-size: 0.78rem; margin-top: 8px; }

.card .actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 8px;
  flex-shrink: 0;
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1200; font-weight: 600; }
.vote-group { display: flex; gap: 6px; }
.btn.vote { min-width: 54px; font-variant-numeric: tabular-nums; }
.btn.vote.up.voted { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.btn.vote.down.voted { background: #4a1f1c; border-color: var(--bad); color: var(--bad); }
.btn.danger { color: var(--bad); font-size: 0.78rem; padding: 4px 8px; border: none; background: none; }
.btn.audible { font-size: 0.8rem; }

.badge {
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.badge.owned { color: var(--good); border-color: var(--good); }

.card .claim { color: var(--good); font-size: 0.85rem; margin: 4px 0 0; }
.card.is-claimed { border-color: var(--good); }
.btn.claim { color: var(--good); border-color: var(--good); }
.btn.claim.claimed { color: var(--muted); border-color: var(--border); }

/* freshly-added-to-wishlist feedback */
.check-pop {
  position: fixed;
  transform: translate(-50%, -50%);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--good);
  pointer-events: none;
  z-index: 30;
  animation: check-burst 750ms ease-out forwards;
}
@keyframes check-burst {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  40% { opacity: 1; transform: translate(-50%, -80%) scale(1.5); }
  100% { opacity: 0; transform: translate(-50%, -140%) scale(1); }
}
.card.just-added { animation: added-pulse 1000ms ease-out; }
@keyframes added-pulse {
  0% { border-color: var(--good); box-shadow: 0 0 0 0 rgba(76, 195, 138, 0.5); }
  100% { border-color: var(--border); box-shadow: 0 0 0 10px rgba(76, 195, 138, 0); }
}
.wl-added { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.wl-added .badge.added { color: var(--good); border-color: var(--good); }
.wl-added.reveal { animation: wl-reveal 400ms ease-out; }
@keyframes wl-reveal {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

.recent .card { opacity: 0.75; }

.club-goal { color: var(--accent); font-size: 0.9rem; margin: 12px 4px 0; }
.goal-admin { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 10px 4px 0; font-size: 0.85rem; }
.btn.end-pick { color: var(--bad); border-color: var(--bad); background: none; font-size: 0.82rem; padding: 6px 10px; }
.goal-admin input[type="date"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 6px 10px;
  color-scheme: dark;
}

.member-row { margin-bottom: 16px; }
.member-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 5px; }
.member-name { font-weight: 600; }
.member-stats { color: var(--muted); font-size: 0.8rem; text-align: right; }
.pbar {
  height: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.pbar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  min-width: 2px;
  transition: width 400ms ease;
}
.pbar-fill.done { background: var(--good); }
.pbar-fill.zero { min-width: 0; }
.recent .card .cover { min-width: 56px; min-height: 56px; }

.empty { color: var(--muted); text-align: center; padding: 32px 12px; }

.search-bar input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 1rem;
  margin-bottom: 14px;
}
.search-bar input:focus { outline: none; border-color: var(--accent); }

.modal-backdrop[hidden] { display: none; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  width: 100%;
  max-width: 380px;
}
.modal h2 { margin: 0 0 4px; color: var(--text); }
.muted { color: var(--muted); font-size: 0.88rem; }

.chip.user { cursor: pointer; }
.chip.user:hover { border-color: var(--accent); }

.banner a { color: var(--accent); }

#login-form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
#login-form input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 1rem;
}
#login-form input:focus { outline: none; border-color: var(--accent); }
.btn.wide { width: 100%; padding: 10px; font-size: 1rem; }
.login-error { color: var(--bad); font-size: 0.85rem; margin: 0; }

.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.modal.features { max-width: 560px; max-height: 82vh; overflow-y: auto; }
.modal.features > .btn.primary { margin-bottom: 14px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-head h2 { margin: 0; }
.modal-head .btn { padding: 4px 10px; }
.feature-cards .card .body p.request-text { margin: 0 0 4px; white-space: pre-wrap; }
#feature-form textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  font-size: 0.95rem;
  resize: vertical;
  margin-top: 12px;
}
#feature-form textarea:focus { outline: none; border-color: var(--accent); }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
.center { text-align: center; }
.muted a { color: var(--muted); }

.lip-pop {
  position: fixed;
  transform: translate(-50%, -50%);
  font-size: 1.7rem;
  pointer-events: none;
  z-index: 30;
  animation: lip-float 900ms ease-out forwards;
}
@keyframes lip-float {
  0% { opacity: 0; transform: translate(-50%, -10%) scale(0.4); }
  25% { opacity: 1; transform: translate(-50%, -70%) scale(1.3); }
  100% { opacity: 0; transform: translate(-50%, -200%) scale(1) rotate(-12deg); }
}

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.9rem;
  z-index: 20;
  max-width: 90vw;
}
#toast.error { border-color: var(--bad); }

@media (max-width: 540px) {
  .card { flex-wrap: wrap; }
  .card .cover { max-height: 110px; }
  .card .actions { flex-direction: row; width: 100%; justify-content: flex-end; align-items: center; }
}
