.cookie-preferences {
  --cookie-preferences-radius: 1.25rem;
  --cookie-preferences-bottom-offset: calc(5.75rem + env(safe-area-inset-bottom));

  position: fixed;
  z-index: 1050;
  right: max(1rem, env(safe-area-inset-right));
  bottom: var(--cookie-preferences-bottom-offset);
  width: min(28rem, calc(100% - max(1rem, env(safe-area-inset-left)) - max(1rem, env(safe-area-inset-right))));
  max-height: calc(100svh - var(--cookie-preferences-bottom-offset) - max(1rem, env(safe-area-inset-top)));
  border: 1px solid var(--color-border-overlay);
  border-radius: var(--cookie-preferences-radius);
  overflow: auto;
  background-color: var(--color-surface-overlay);
  box-shadow:
    inset 0 1px 0 var(--color-border-overlay),
    0 1.5rem 4rem var(--color-shadow-overlay);
  color: var(--color-text-default);
  opacity: 0;
  overscroll-behavior: contain;
  transform: translateY(0.75rem) scale(0.985);
  transition: opacity 180ms ease, transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

@media (min-width: 600px) {
  .cookie-preferences {
    --cookie-preferences-bottom-offset: max(1rem, env(safe-area-inset-bottom));
  }
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .cookie-preferences {
    background-color: var(--color-surface-glass);
    -webkit-backdrop-filter: blur(1.75rem) saturate(155%) contrast(102%);
    backdrop-filter: blur(1.75rem) saturate(155%) contrast(102%);
  }
}

.cookie-preferences.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.cookie-preferences__form {
  padding: 1.25rem;
}

.cookie-preferences__header {
  min-width: 0;
}

.cookie-preferences__title {
  max-width: 20ch;
  margin: 0;
  color: var(--color-text-heading);
  font-size: 1.375rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.2;
  text-wrap: balance;
}

@media (min-width: 600px) {
  .cookie-preferences__title {
    font-size: 1.5rem;
    line-height: 1.08;
  }
}

.cookie-preferences__description {
  max-width: 46ch;
  margin: 0.75rem 0 0;
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1.5;
  text-wrap: pretty;
}

@media (min-width: 600px) {
  .cookie-preferences__description {
    margin-top: 0.5rem;
    font-size: 0.9375rem;
  }
}

.cookie-preferences__categories {
  min-width: 0;
  padding: 0;
  border: 0;
  margin: 1rem 0 0;
}

@media (min-width: 600px) {
  .cookie-preferences__categories {
    margin-top: 0.75rem;
  }
}

.cookie-preferences__category-list {
  border-top: 1px solid var(--color-border-default);
  border-bottom: 1px solid var(--color-border-default);
}

.cookie-preferences-category {
  display: flex;
  min-width: 0;
  min-height: 4.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 0.25rem;
  cursor: pointer;
  gap: 1rem;
}

.cookie-preferences-category + .cookie-preferences-category {
  border-top: 1px solid var(--color-border-default);
}

.cookie-preferences-category:not(.is-required):hover {
  background-color: var(--color-surface-interactive);
}

.cookie-preferences-category:has(.cookie-preferences-toggle__input:focus-visible) {
  border-radius: var(--control-radius-compact);
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

.cookie-preferences-category.is-required {
  cursor: default;
}

.cookie-preferences-category__copy {
  min-width: 0;
  flex: 1 1 auto;
}

.cookie-preferences-category__heading {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem 0.5rem;
}

.cookie-preferences-category__label {
  color: var(--color-text-heading);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

@media (min-width: 600px) {
  .cookie-preferences-category__label {
    font-size: 0.9375rem;
  }
}

.cookie-preferences-category__badge {
  padding: 0.1875rem 0.5rem;
  border-radius: var(--control-radius-pill);
  background-color: var(--color-surface-interactive);
  color: var(--color-interactive);
  font-size: var(--font-size-label);
  font-weight: 700;
  line-height: 1.25;
}

.cookie-preferences-category__description {
  display: block;
  margin-top: 0.25rem;
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1.4;
  text-wrap: pretty;
}

@media (min-width: 600px) {
  .cookie-preferences-category__description {
    font-size: 0.875rem;
  }
}

.cookie-preferences-category__tracking-types {
  display: block;
  margin-top: 0.375rem;
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1.4;
  text-wrap: pretty;
}

@media (min-width: 600px) {
  .cookie-preferences-category__tracking-types {
    font-size: 0.875rem;
  }
}

.cookie-preferences-category__tracking-types-label {
  color: var(--color-text-default);
  font-weight: 600;
}

.cookie-preferences-toggle {
  position: relative;
  display: inline-flex;
  width: 3.25rem;
  height: 2rem;
  padding: 0.1875rem;
  border: 1px solid var(--color-border-default);
  border-radius: var(--control-radius-pill);
  background-color: var(--color-surface-media);
  flex: 0 0 auto;
  transition: transform var(--control-transition-duration) ease;
}

@media (min-width: 600px) {
  .cookie-preferences-toggle {
    width: 2.75rem;
    height: 1.75rem;
  }
}

.cookie-preferences-toggle:has(.cookie-preferences-toggle__input:checked) {
  border-color: var(--color-brand-primary);
  background-color: var(--color-brand-primary);
  background-image: linear-gradient(105deg, var(--color-brand-primary), var(--color-brand-secondary));
}

.cookie-preferences-toggle__input {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
  opacity: 0;
}

.cookie-preferences-toggle__input:disabled {
  cursor: default;
}

.cookie-preferences-toggle__thumb {
  width: 1.625rem;
  height: 1.625rem;
  border-radius: 50%;
  background-color: var(--color-surface-fixed-light);
  box-shadow: 0 1px 4px rgb(20 35 50 / 20%);
  pointer-events: none;
  transform: translateX(0);
  transition: transform 200ms ease;
}

@media (min-width: 600px) {
  .cookie-preferences-toggle__thumb {
    width: 1.375rem;
    height: 1.375rem;
  }
}

.cookie-preferences-toggle__input:checked + .cookie-preferences-toggle__thumb {
  transform: translateX(1.25rem);
}

@media (min-width: 600px) {
  .cookie-preferences-toggle__input:checked + .cookie-preferences-toggle__thumb {
    transform: translateX(1rem);
  }
}

.cookie-preferences-category.is-required .cookie-preferences-toggle {
  opacity: 0.72;
}

.cookie-preferences__actions {
  display: grid;
  margin-top: 1.25rem;
  gap: 0.5rem;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 600px) {
  .cookie-preferences__actions {
    margin-top: 0.75rem;
  }
}

.cookie-preferences__secondary-actions {
  display: grid;
  min-width: 0;
  gap: 0.5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cookie-preferences__secondary-actions > :only-child {
  grid-column: 1 / -1;
}

.cookie-preferences__button {
  display: inline-flex;
  min-width: 0;
  min-height: var(--control-hit-area-min);
  align-items: center;
  justify-content: center;
  padding: 0.625rem 0.875rem;
  border: 1px solid transparent;
  border-radius: var(--control-radius-default);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

@media (min-width: 600px) {
  .cookie-preferences__button {
    font-size: 0.9375rem;
  }
}

.cookie-preferences__button--primary {
  min-height: 3.5rem;
  border-color: var(--color-brand-primary);
  background-color: var(--color-brand-primary);
  color: var(--color-text-on-action);
  font-weight: 700;
}

.cookie-preferences__button--secondary {
  border-color: var(--color-border-interactive);
  background-color: transparent;
  color: var(--color-interactive);
}

.cookie-preferences__button--save {
  display: none;
}

.cookie-preferences.is-managing .cookie-preferences__button--save {
  display: inline-flex;
}

.cookie-preferences.is-managing .cookie-preferences__button--accept {
  display: none;
}

.cookie-preferences__button:hover {
  border-color: var(--color-interactive-hover);
}

.cookie-preferences__button--primary:hover {
  border-color: var(--color-brand-primary-darkened);
  background-color: var(--color-brand-primary-darkened);
}

.cookie-preferences__button--secondary:hover {
  background-color: var(--color-surface-interactive);
  color: var(--color-interactive-hover);
}

.cookie-preferences__button:focus-visible,
.cookie-preferences__footer-action:focus-visible,
.cookie-preferences-fallback__link:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

.cookie-preferences__status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  color: var(--color-text-error);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
}

@media (min-width: 600px) {
  .cookie-preferences__status {
    font-size: var(--font-size-label);
  }
}

.cookie-preferences__status.is-error {
  position: static;
  width: auto;
  height: auto;
  margin: 0.5rem 0 0;
  overflow: visible;
  clip: auto;
  clip-path: none;
  white-space: normal;
}

.cookie-preferences__footer {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
}

@media (min-width: 600px) {
  .cookie-preferences__footer {
    margin-top: 0.25rem;
  }
}

.cookie-preferences__footer-action {
  display: inline-flex;
  width: 100%;
  min-height: var(--control-hit-area-min);
  align-items: center;
  justify-content: center;
  padding: 0.375rem 0.5rem;
  border: 0;
  background: transparent;
  color: var(--color-interactive);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
}

@media (min-width: 600px) {
  .cookie-preferences__footer-action {
    font-size: 0.9375rem;
  }
}

.cookie-preferences__footer-action::after {
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentcolor;
  border-bottom: 2px solid currentcolor;
  margin: -0.25rem 0 0 0.5rem;
  content: "";
  transform: rotate(45deg);
}

.cookie-preferences.is-managing .cookie-preferences__footer-action::after {
  margin-top: 0.25rem;
  transform: rotate(225deg);
}

.cookie-preferences__footer-action:hover {
  color: var(--color-interactive-hover);
}

.cookie-preferences-fallback {
  width: min(48rem, calc(100% - 2 * max(1rem, env(safe-area-inset-left), env(safe-area-inset-right))));
  padding: 1.25rem;
  border: 1px solid var(--color-border-default);
  margin: 1rem auto calc(6.75rem + env(safe-area-inset-bottom));
  border-radius: var(--cookie-preferences-radius, 1.25rem);
  background-color: var(--color-surface-overlay);
}

@media (min-width: 600px) {
  .cookie-preferences-fallback {
    padding: 0.875rem;
    margin-bottom: max(1rem, env(safe-area-inset-bottom));
  }
}

.cookie-preferences-fallback__title {
  margin: 0;
  color: var(--color-text-heading);
  font-size: 1rem;
  font-weight: 700;
}

.cookie-preferences-fallback__description {
  margin: 0.5rem 0 0;
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1.5;
}

.cookie-preferences-fallback__link {
  display: inline-flex;
  min-height: var(--control-hit-area-min);
  align-items: center;
  margin-top: 0.25rem;
  color: var(--color-interactive);
  font-weight: 600;
  text-underline-offset: 0.18em;
}

html[data-resolved-theme="dark"] .cookie-preferences,
html[data-resolved-theme="dark"] .cookie-preferences-fallback {
  box-shadow: inset 0 1px 0 var(--color-border-overlay);
}

html[data-resolved-theme="dark"] .cookie-preferences-toggle__thumb {
  box-shadow: none;
}

@media (prefers-reduced-transparency: reduce) {
  .cookie-preferences {
    background-color: var(--color-surface-raised);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cookie-preferences {
    transition: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cookie-preferences-toggle__thumb {
    transition: none;
  }
}

@media (forced-colors: active) {
  .cookie-preferences {
    border: 2px solid CanvasText;
    background: Canvas;
    box-shadow: none;
    color: CanvasText;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

@media (forced-colors: active) {
  .cookie-preferences-fallback {
    border: 2px solid CanvasText;
    background: Canvas;
    box-shadow: none;
    color: CanvasText;
  }
}

@media (forced-colors: active) {
  .cookie-preferences-toggle {
    border: 2px solid CanvasText;
    background: Canvas;
  }
}

@media (forced-colors: active) {
  .cookie-preferences-toggle__thumb {
    background: CanvasText;
    box-shadow: none;
  }
}
