:root {
  --bg: #0D1520;
  --surface: #152131;
  --surface-2: #1C2B40;
  --border: #25364F;
  --ink: #F5F2EB;
  --muted: #9FB0C4;
  --gold: #E5A93B;
  --gold-ink: #1A1204;
  --teal: #2BB8A0;
  --teal-ink: #041D19;
  --danger: #E05A5A;
  --r-color: #3B82F6;
  --k-color: #E5A93B;
  --m-color: #2BB8A0;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  padding-bottom: 92px;
  min-height: 100dvh;
}

/* Identity Gate */
.gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: radial-gradient(circle at top, #18283E 0%, #0D1520 72%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.gate.hidden { display: none; }

.gate-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 26px 22px;
  text-align: center;
}

.gate-lang {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
}

.lang-chip {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.lang-chip.active {
  background: var(--gold);
  color: var(--gold-ink);
  border-color: var(--gold);
}

.gate-crest {
  font-size: 34px;
  margin-bottom: 8px;
}

.gate-card h1 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
}

.gate-sub {
  color: var(--gold);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 20px;
}

.gate-ask {
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.profile-btn {
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 16px 8px;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform .15s, border-color .15s;
}
.profile-btn:hover, .profile-btn:active {
  border-color: var(--gold);
  transform: translateY(-2px);
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
}
.avatar-sm {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}
.av-r { background: var(--r-color); }
.av-k { background: var(--k-color); color: var(--gold-ink); }
.av-m { background: var(--m-color); color: var(--teal-ink); }

.profile-name { font-size: 16px; font-weight: 800; }
.profile-count {
  font-size: 12px;
  color: var(--muted);
  background: rgba(255,255,255,0.06);
  padding: 2px 10px;
  border-radius: 999px;
}

.gate-hint {
  font-size: 13px;
  color: var(--muted);
}

/* Top Bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(13, 21, 32, 0.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px 12px;
}

.topbar-row {
  max-width: 960px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.user-pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: 999px;
  padding: 5px 12px 5px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.chev { color: var(--muted); font-size: 12px; }

.lang-switch {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.lang-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.lang-btn.active {
  background: var(--gold);
  color: var(--gold-ink);
}

.budget-bar-wrap {
  max-width: 960px;
  margin: 0 auto;
}
.budget-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}
.sync-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--teal);
  background: rgba(43, 184, 160, 0.14);
  padding: 2px 8px;
  border-radius: 999px;
}
.budget-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.budget-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  border-radius: 999px;
  transition: width .25s ease;
}
.budget-fill.over { background: var(--danger); }

/* Main Container */
.main {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 14px 20px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Category Chips */
.cat-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 8px;
  scrollbar-width: none;
}
.cat-scroll::-webkit-scrollbar { display: none; }

.cat-chip {
  flex-shrink: 0;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 15px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.cat-chip.active {
  background: var(--gold);
  color: var(--gold-ink);
  border-color: var(--gold);
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
@media (max-width: 720px) {
  .cards-grid { grid-template-columns: 1fr; }
}

.act-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .18s;
}
.act-card.voted {
  border-color: var(--teal);
}

/* Swipeable 3-Photo Carousel */
.carousel-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #091019;
  overflow: hidden;
}

.carousel-track {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  direction: ltr;
}
.carousel-track::-webkit-scrollbar { display: none; }

.carousel-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  cursor: zoom-in;
}
.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.car-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(13, 21, 32, 0.72);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
  z-index: 4;
}
.car-prev { left: 10px; }
.car-next { right: 10px; }

.car-counter {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(13, 21, 32, 0.78);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  z-index: 4;
}

.price-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--gold);
  color: var(--gold-ink);
  font-size: 13px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 10px;
  z-index: 4;
}

.car-dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 4;
}
.car-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.45);
  transition: transform .15s, background .15s;
}
.car-dot.active {
  background: #fff;
  transform: scale(1.3);
}

/* Card Body */
.card-body {
  padding: 14px 15px 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-top-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.card-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.3;
}

.card-desc {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.45;
}

.voters-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
  min-height: 30px;
}

.voter-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.vote-score {
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
}

.btn-vote {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.act-card.voted .btn-vote {
  background: var(--teal);
  color: var(--teal-ink);
  border-color: var(--teal);
}

.btn-link {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.btn-link:hover { border-color: var(--gold); color: var(--gold); }

/* Poll Tab */
.poll-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 16px;
}
.poll-hero h2 { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.poll-hero p { font-size: 13.5px; color: var(--muted); margin-bottom: 14px; }

.voter-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.vs-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 7px 12px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.share-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 520px) { .share-actions { grid-template-columns: 1fr; } }

.btn-wa, .btn-copy {
  min-height: 46px;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.btn-wa { background: #25D366; color: #052211; }
.btn-copy { background: var(--gold); color: var(--gold-ink); }

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

.poll-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.poll-row.top3 { border-color: var(--gold); }

.poll-thumb {
  width: 74px;
  height: 58px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.poll-info { flex: 1; min-width: 0; }
.poll-name { font-size: 15px; font-weight: 800; }
.poll-sub { font-size: 12px; color: var(--muted); }

.poll-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.poll-count {
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 70;
  background: rgba(13, 21, 32, 0.96);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  gap: 10px;
}

.nav-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 14px;
  padding: 10px 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.nav-btn.active {
  background: var(--gold);
  color: var(--gold-ink);
  border-color: var(--gold);
}
.nav-badge {
  background: rgba(0,0,0,0.25);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(5, 8, 13, 0.94);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 96vw;
  max-height: 82vh;
  border-radius: 14px;
  object-fit: contain;
}
.lb-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
.lb-caption {
  margin-top: 12px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--teal);
  color: var(--teal-ink);
  font-weight: 800;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 12px;
  display: none;
  z-index: 250;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
