:root {
  --bg: #0e0f14;
  --bg-elevated: #171923;
  --bg-surface: #1f2230;
  --bg-hover: #272b3c;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-soft: #cbd5e1;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.16);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #fb7185;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.45);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

button {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ================= HEADER & NAV ================= */

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(14, 15, 20, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (min-width: 780px) {
  .app-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
  }
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1e293b, #312e81);
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-progress {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
  white-space: nowrap;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.sync-pill[data-state='saved'] .sync-dot,
.sync-pill[data-state='idle'] .sync-dot {
  background: var(--success);
}

.sync-pill[data-state='pending'] .sync-dot,
.sync-pill[data-state='syncing'] .sync-dot {
  background: var(--warning);
  animation: pulse 1.1s infinite ease-in-out;
}

.sync-pill[data-state='error'] .sync-dot {
  background: var(--danger);
}

.tab-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: 14px;
  border: 1px solid var(--border);
}

@media (min-width: 780px) {
  .tab-bar {
    min-width: 320px;
  }
}

.tab-btn {
  min-height: 38px;
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.65);
  animation: liveRing 2s infinite;
}

@keyframes liveRing {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ================= SWIPE MODE ================= */

.swipe-layout {
  flex: 1;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 12px 14px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: calc(100dvh - 112px);
}

@media (min-width: 780px) {
  .swipe-layout {
    padding: 18px 24px 24px;
    min-height: calc(100dvh - 70px);
  }
}

.swipe-meta-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.swipe-meta-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.swipe-counter {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.swipe-order {
  font-size: 1rem;
  font-weight: 700;
}

.swipe-date {
  font-size: 0.86rem;
  color: var(--text-muted);
}

.jump-unvoted-btn {
  min-height: 34px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.35);
  font-size: 0.78rem;
  font-weight: 600;
  transition: transform 0.14s ease, background-color 0.14s ease;
}

.jump-unvoted-btn:hover {
  background: rgba(56, 189, 248, 0.25);
}

.progress-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-surface);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #818cf8, #fb7185);
  transition: width 0.26s ease;
}

.swipe-stage {
  position: relative;
  flex: 1;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: pan-y;
}

.swipe-card {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: 58dvh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
  cursor: grab;
  will-change: transform, opacity;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease;
}

.swipe-card.is-dragging {
  cursor: grabbing;
  transition: none;
}

.swipe-card.anim-leave-left {
  transform: translateX(-115%) rotate(-6deg) !important;
  opacity: 0;
}

.swipe-card.anim-leave-right {
  transform: translateX(115%) rotate(6deg) !important;
  opacity: 0;
}

.swipe-card.anim-enter {
  animation: cardEnter 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.swipe-image-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #090a0e;
  display: flex;
  align-items: center;
  justify-content: center;
}

.swipe-image {
  width: 100%;
  height: 100%;
  max-height: 52dvh;
  object-fit: contain;
  pointer-events: none;
}

.swipe-zoom-hint {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(14, 15, 20, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 0.75rem;
  color: var(--text-soft);
  backdrop-filter: blur(8px);
}

.swipe-voted-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(14, 15, 20, 0.84);
  border: 1px solid var(--badge-color, var(--border-strong));
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.swipe-drag-hint {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(14, 15, 20, 0.86);
  border: 1px solid var(--border-strong);
  font-size: 0.9rem;
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s ease;
}

.swipe-drag-hint.prev {
  left: 16px;
}

.swipe-drag-hint.next {
  right: 16px;
}

.swipe-caption {
  padding: 10px 14px;
  font-size: 0.86rem;
  color: var(--text-soft);
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emoji-burst {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 4.5rem;
  pointer-events: none;
  animation: burstPop 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  z-index: 5;
}

@keyframes burstPop {
  0% {
    opacity: 0;
    transform: scale(0.4);
  }
  45% {
    opacity: 1;
    transform: scale(1.18);
  }
  100% {
    opacity: 0;
    transform: scale(1.45) translateY(-16px);
  }
}

.swipe-dock {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.category-dock {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.cat-btn {
  min-height: 68px;
  padding: 8px 6px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: transform 0.14s ease, border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.cat-btn:hover {
  background: var(--bg-surface);
  border-color: var(--border-strong);
}

.cat-btn:active {
  transform: scale(0.95);
}

.cat-btn.is-selected {
  background: var(--cat-soft, var(--accent-soft));
  border-color: var(--cat-color, var(--accent));
  box-shadow: 0 0 0 1px var(--cat-color, var(--accent)), 0 8px 22px rgba(0, 0, 0, 0.35);
}

.cat-emoji {
  font-size: 1.65rem;
  line-height: 1;
}

.cat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-soft);
  text-align: center;
  line-height: 1.15;
}

@media (min-width: 640px) {
  .cat-btn {
    min-height: 74px;
    padding: 10px 12px;
  }
  .cat-emoji {
    font-size: 1.85rem;
  }
  .cat-label {
    font-size: 0.82rem;
  }
}

.swipe-nav-row {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 8px;
}

.nav-action-btn {
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.15s ease, transform 0.12s ease;
}

.nav-action-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-action-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.nav-action-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.nav-action-btn.primary {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  border-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.swipe-kbd-hint {
  display: none;
  justify-content: center;
  gap: 16px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

@media (hover: hover) and (pointer: fine) {
  .swipe-kbd-hint {
    display: flex;
  }
}

/* Completion Card */
.swipe-complete-card {
  width: 100%;
  padding: 28px 22px;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, #171923 0%, #1e1b36 100%);
  border: 1px solid var(--border-strong);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-lg);
}

.complete-emoji {
  font-size: 3.2rem;
}

.swipe-complete-card h2 {
  margin: 0;
  font-size: 1.35rem;
}

.swipe-complete-card p {
  margin: 0;
  color: var(--text-soft);
  max-width: 420px;
  line-height: 1.5;
}

.complete-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.btn-pill {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.16s ease, transform 0.14s ease;
}

.btn-pill:hover {
  background: var(--bg-hover);
}

.btn-pill.primary {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-color: transparent;
}

/* ================= GRID MODE ================= */

.grid-layout {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (min-width: 780px) {
  .grid-layout {
    padding: 20px 24px 36px;
  }
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.filter-chip {
  min-height: 40px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.filter-chip:hover {
  background: var(--bg-surface);
}

.filter-chip.active {
  background: var(--chip-soft, var(--accent-soft));
  border-color: var(--chip-color, var(--accent));
  color: #ffffff;
}

.filter-count {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.74rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (min-width: 640px) {
  .photo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
  }
}

@media (min-width: 960px) {
  .photo-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .photo-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.grid-card {
  position: relative;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  content-visibility: auto;
  contain-intrinsic-size: 260px;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.grid-card.is-voted {
  border-color: var(--voted-color, var(--border-strong));
}

.grid-thumb-btn {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  background: #0a0b10;
  overflow: hidden;
  padding: 0;
}

.grid-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

@media (hover: hover) {
  .grid-card:hover .grid-thumb-img {
    transform: scale(1.03);
  }
}

.grid-top-badges {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}

.grid-order-pill {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(14, 15, 20, 0.72);
  backdrop-filter: blur(6px);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-soft);
}

.grid-voted-pill {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(14, 15, 20, 0.85);
  border: 1px solid var(--voted-color, var(--border-strong));
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.grid-quick-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
}

/* Sur ordinateur avec survol fin, barre compacte révélée au survol ou si déjà voté */
@media (hover: hover) and (pointer: fine) {
  .grid-quick-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(14, 15, 20, 0.86);
    backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.16s ease, transform 0.16s ease;
  }

  .grid-card:hover .grid-quick-bar,
  .grid-card:focus-within .grid-quick-bar {
    opacity: 1;
    transform: translateY(0);
  }
}

.grid-emoji-btn {
  min-height: 36px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid transparent;
  font-size: 1.15rem;
  display: grid;
  place-items: center;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.grid-emoji-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.grid-emoji-btn:active {
  transform: scale(0.9);
}

.grid-emoji-btn.is-selected {
  background: var(--cat-soft, var(--accent-soft));
  border-color: var(--cat-color, var(--accent));
}

.grid-empty {
  padding: 48px 20px;
  text-align: center;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
}

/* ================= LEADERBOARD MODE ================= */

.lb-layout {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 780px) {
  .lb-layout {
    padding: 20px 24px 40px;
  }
}

.lb-toolbar {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lb-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lb-stats-main {
  font-size: 0.98rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lb-stats-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.lb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lb-btn {
  min-height: 40px;
  padding: 8px 13px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lb-btn:hover {
  background: var(--bg-hover);
}

.lb-categories-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 900px) {
  .lb-categories-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.lb-cat-card {
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lb-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.lb-cat-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1.05rem;
  font-weight: 700;
}

.lb-cat-total {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-surface);
}

.lb-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lb-item {
  display: grid;
  grid-template-columns: 36px 68px 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  transition: background-color 0.15s ease;
}

.lb-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.lb-rank {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.9rem;
  background: var(--bg-surface);
  color: var(--text-soft);
}

.lb-rank.rank-1 {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #111827;
}

.lb-rank.rank-2 {
  background: linear-gradient(135deg, #94a3b8, #e2e8f0);
  color: #111827;
}

.lb-rank.rank-3 {
  background: linear-gradient(135deg, #b45309, #f97316);
  color: #ffffff;
}

.lb-thumb-btn {
  width: 68px;
  height: 68px;
  border-radius: 10px;
  overflow: hidden;
  background: #0a0b10;
  padding: 0;
  flex-shrink: 0;
}

.lb-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lb-item-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.lb-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lb-photo-meta {
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-vote-count {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--cat-color, var(--accent));
  white-space: nowrap;
}

.lb-bar-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-surface);
  overflow: hidden;
}

.lb-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--cat-color, var(--accent));
  transition: width 0.3s ease;
}

.lb-item-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.lb-my-vote-tag {
  color: var(--success);
  font-weight: 600;
}

.lb-empty {
  padding: 22px 12px;
  text-align: center;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.lb-error-banner {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(251, 113, 133, 0.14);
  border: 1px solid rgba(251, 113, 133, 0.35);
  color: #fecdd3;
  font-size: 0.88rem;
  line-height: 1.45;
}

/* ================= LIGHTBOX ================= */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(8, 9, 13, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  padding: 12px;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  gap: 10px;
}

.lbx-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
}

.lbx-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.lbx-order {
  font-size: 0.96rem;
  font-weight: 700;
}

.lbx-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.lbx-close {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  font-size: 1.25rem;
  display: grid;
  place-items: center;
}

.lbx-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lbx-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.lbx-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(14, 15, 20, 0.78);
  border: 1px solid var(--border-strong);
  font-size: 1.2rem;
  display: grid;
  place-items: center;
}

.lbx-arrow.prev {
  left: 8px;
}

.lbx-arrow.next {
  right: 8px;
}

.lbx-footer {
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lbx-caption {
  text-align: center;
  font-size: 0.86rem;
  color: var(--text-soft);
}

.lbx-vote-counts {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.lbx-vote-pill {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

/* ================= TOAST & LOADING ================= */

.toast-region {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(92vw, 420px);
}

.toast {
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(23, 25, 35, 0.95);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  animation: toastIn 0.18s ease;
}

.toast[data-type='error'] {
  border-color: var(--danger);
  color: #fecdd3;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.loading-state {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}
