.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.switch input {
  display: none;
}
.switch .slider {
  width: 44px;
  height: 26px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  position: relative;
  display: inline-block;
}
.switch .slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: transform 0.2s ease;
}
.switch input:checked + .slider::after {
  transform: translateX(18px);
}
.switch-label {
  color: var(--muted);
  font-size: 14px;
}
.switch input:focus + .slider {
  outline: 2px dashed var(--border);
  outline-offset: 2px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 13px;
}

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.06) 25%,
    rgba(0, 0, 0, 0.12) 37%,
    rgba(0, 0, 0, 0.06) 63%
  );
  border-radius: 8px;
  animation: shine 1.4s ease infinite;
}
@keyframes shine {
  0% {
    background-position: -100px 0;
  }
  100% {
    background-position: 100px 0;
  }
}

/* Flag chip with hover pop image */
.flag-chip-wrapper {
  position: relative;
  display: inline-block;
}
.flag-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  box-shadow: var(--shadow);
}
.flag-chip .icon {
  width: 18px;
  height: 12px;
  display: inline-block;
}
.flag-pop {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translate(-50%, 8px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.18), 0 0 0 0 rgba(115,79,47,0.0);
  transition: opacity 220ms ease, transform 220ms ease;
  z-index: 20;
}
.flag-pop img {
  display: block;
  width: 220px;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.22);
}
.flag-chip-wrapper:hover .flag-pop,
.flag-chip-wrapper:focus-within .flag-pop {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  /* springy pop-in */
  animation: flag-pop-in 340ms cubic-bezier(.22,1.28,.23,1) both;
}
@media (prefers-reduced-motion: reduce) {
  .flag-pop { transition: none; transform: translate(-50%, 0); animation: none !important; }
}

/* Liquid-like micro-interactions */
.flag-chip-wrapper:hover .flag-chip,
.flag-chip-wrapper:focus-within .flag-chip {
  animation: flag-chip-squish 460ms cubic-bezier(.34,1.56,.64,1);
}

/* Soft animated blob behind the popover image */
.flag-pop { position: absolute; overflow: visible; }
.flag-pop::before {
  content: "";
  position: absolute;
  inset: -18px -20px -24px -20px;
  background: radial-gradient(45% 45% at 50% 50%, rgba(115,79,47,0.18), rgba(115,79,47,0.08) 60%, transparent 72%);
  border-radius: 28px;
  filter: blur(18px);
  z-index: -1;
  animation: flag-blob 4.8s ease-in-out infinite alternate;
}
/* Extra pulsating accent glow */
.flag-pop::after {
  content: "";
  position: absolute;
  inset: -26px -28px -30px -28px;
  border-radius: 32px;
  background: radial-gradient(50% 50% at 50% 50%, rgba(115,79,47,0.14), rgba(115,79,47,0.05) 60%, transparent 75%);
  filter: blur(22px);
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 200ms ease;
  z-index: -2;
}
.flag-chip-wrapper:hover .flag-pop::after,
.flag-chip-wrapper:focus-within .flag-pop::after {
  opacity: 1;
  animation: flag-glow-pulse 2.2s ease-in-out infinite;
}

@keyframes flag-pop-in {
  0%   { transform: translate(-50%, 14px) scale(0.9); opacity: 0; }
  60%  { transform: translate(-50%, -4px) scale(1.06); opacity: 1; }
  100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

@keyframes flag-chip-squish {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.08, 0.94); }
  65%  { transform: scale(0.97, 1.03); }
  100% { transform: scale(1); }
}

@keyframes flag-blob {
  0%   { transform: translateY(3px) scale(1, 1); border-radius: 26px; }
  50%  { transform: translateY(-3px) scale(1.05, 0.97); border-radius: 30px; }
  100% { transform: translateY(0) scale(0.97, 1.03); border-radius: 24px; }
}

@keyframes flag-glow-pulse {
  0%   { transform: scale(0.98); opacity: 0.65; }
  50%  { transform: scale(1.03); opacity: 1; }
  100% { transform: scale(0.99); opacity: 0.75; }
}
