:root {
  --pref-bar-height: 40px;
}

/* ── Preference bar ─────────────────────────────────────── */
.pref-bar {
  --pref-accent: #6c8cff;
  --pref-accent-soft: rgba(108, 140, 255, 0.12);
  --pref-surface: #0f1117;
  --pref-text: #f4f6fb;
  --pref-muted: rgba(244, 246, 251, 0.55);

  position: sticky;
  top: 0;
  z-index: 1100;
  background: var(--pref-surface);
}

/* Theme header becomes fixed on scroll; keep it below the pref bar */
.header.header-fixed,
.header.header-transparent.header-fixed,
.header.header-light.head-fixed {
  top: var(--pref-bar-height);
}

.pref-bar__row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.15rem;
  min-height: 40px;
  padding: 0.25rem 0;
  flex-wrap: wrap;
}

/* ── Dropdown ───────────────────────────────────────────── */
.pref-dd {
  position: relative;
}

.pref-dd + .pref-dd::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 50%;
  width: 1px;
  height: 14px;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

.pref-dd__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 220px;
  padding: 0.4rem 0.75rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--pref-text);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.pref-dd__btn:hover,
.pref-dd.is-open .pref-dd__btn {
  background: rgba(255, 255, 255, 0.08);
}

.pref-dd__icon {
  display: none;
}

.pref-dd__meta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  text-align: start;
}

.pref-dd__label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--pref-muted);
  white-space: nowrap;
}

.pref-dd__label::after {
  content: ":";
}

.pref-dd__value {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--pref-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.pref-dd__chevron {
  font-size: 0.65rem;
  color: var(--pref-muted);
  transition: transform 0.15s ease;
}

.pref-dd.is-open .pref-dd__chevron {
  transform: rotate(180deg);
}

/* ── Menu panel ─────────────────────────────────────────── */
.pref-dd__menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 200px;
  max-width: min(92vw, 260px);
  max-height: 280px;
  overflow-y: auto;
  padding: 0.35rem;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 17, 23, 0.14);
  z-index: 1200;
  animation: prefMenuIn 0.14s ease-out;
}

.pref-dd__menu[hidden] {
  display: none !important;
}

@keyframes prefMenuIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pref-dd__menu-title {
  display: none;
}

.pref-dd__menu form {
  margin: 0;
}

.pref-dd__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #1f2937;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: start;
  cursor: pointer;
  transition: background 0.12s ease;
}

.pref-dd__option-main {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  min-width: 0;
}

.pref-dd__option-main strong {
  font-weight: 650;
}

.pref-dd__option-main em {
  font-style: normal;
  color: #6b7280;
  font-size: 0.8125rem;
}

.pref-dd__option-main span {
  color: #6b7280;
  font-weight: 400;
  font-size: 0.8125rem;
}

.pref-dd__check {
  opacity: 0;
  color: var(--pref-accent);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.pref-dd__option:hover {
  background: #f3f4f6;
}

.pref-dd__option.is-active {
  background: var(--pref-accent-soft);
  color: #3d5fd9;
}

.pref-dd__option.is-active .pref-dd__option-main span,
.pref-dd__option.is-active .pref-dd__option-main em {
  color: #5b74df;
}

.pref-dd__option.is-active .pref-dd__check {
  opacity: 1;
}

@media (max-width: 575.98px) {
  .pref-bar__row {
    justify-content: stretch;
  }

  .pref-dd {
    flex: 1 1 0;
    min-width: 0;
  }

  .pref-dd + .pref-dd::before {
    display: none;
  }

  .pref-dd__btn {
    width: 100%;
    max-width: none;
    justify-content: center;
  }

  .pref-dd__label {
    display: none;
  }

  .pref-dd__value {
    max-width: none;
  }

  .pref-dd__menu {
    inset-inline: 0;
    min-width: 0;
    max-width: none;
  }
}
